kolaslab commited on
Commit
410004f
·
verified ·
1 Parent(s): 3d0bb33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -26
app.py CHANGED
@@ -274,35 +274,27 @@ def make_calendar_heatmap(df, title, year):
274
  @lru_cache(maxsize=100)
275
  def fetch_follower_data(username):
276
  try:
277
- # Make API request to get follower history
278
- # Note: This is a placeholder. Actual API endpoint may differ
279
- url = f"https://huggingface.co/api/users/{username}/followers-history"
280
- response = requests.get(url, timeout=30)
281
 
282
- if response.status_code != 200:
283
- # Simulate some data if API doesn't exist
284
- # This is just for demonstration
285
- import random
286
- from dateutil.relativedelta import relativedelta
287
-
288
- # Generate 12 months of fake data
289
- today = datetime.now()
290
- data = []
291
- followers = random.randint(10, 100)
292
-
293
- for i in range(12):
294
- date = today - relativedelta(months=11-i)
295
- followers += random.randint(0, 10)
296
- data.append({
297
- "date": date.strftime("%Y-%m-%d"),
298
- "followers": followers
299
- })
300
-
301
- return data
302
 
303
- return response.json()
304
  except Exception as e:
305
- st.error(f"Error fetching follower data: {str(e)}")
306
  return []
307
 
308
 
 
274
  @lru_cache(maxsize=100)
275
  def fetch_follower_data(username):
276
  try:
277
+ # Generate fake data for demonstration purposes
278
+ # In a real implementation, this would make an API call to get actual follower data
279
+ import random
280
+ from dateutil.relativedelta import relativedelta
281
 
282
+ # Generate 12 months of fake data
283
+ today = datetime.now()
284
+ data = []
285
+ followers = random.randint(10, 100)
286
+
287
+ for i in range(12):
288
+ date = today - relativedelta(months=11-i)
289
+ followers += random.randint(0, 10)
290
+ data.append({
291
+ "date": date.strftime("%Y-%m-%d"),
292
+ "followers": followers
293
+ })
 
 
 
 
 
 
 
 
294
 
295
+ return data
296
  except Exception as e:
297
+ st.error(f"Error generating follower data: {str(e)}")
298
  return []
299
 
300