openfree commited on
Commit
0bc8f22
ยท
verified ยท
1 Parent(s): 7930c7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -550,7 +550,7 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
550
  }
551
 
552
  if sort_type == "modes":
553
- params['sort'] = 'likes' # modes๋Š” ์ข‹์•„์š” ์ˆœ์œผ๋กœ ์ •๋ ฌ
554
 
555
  try:
556
  progress(0, desc=f"Fetching {sort_type} spaces data...")
@@ -580,15 +580,17 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
580
  ids = [space['id'] for space in spaces]
581
  ranks = [space['rank'] for space in spaces]
582
  likes = [space.get('likes', 0) for space in spaces]
 
583
 
584
- # Y์ถ• ๊ฐ’์„ ๋ฐ˜์ „ (300 - rank + 1)
585
- y_values = [301 - r for r in ranks] # ์ˆœ์œ„๋ฅผ ๋ฐ˜์ „๋œ ๊ฐ’์œผ๋กœ ๋ณ€ํ™˜
586
 
587
  # ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
588
  fig.add_trace(go.Bar(
589
  x=ids,
590
  y=y_values,
591
- text=[f"Rank: {r}<br>Likes: {l}" for r, l in zip(ranks, likes)],
 
592
  textposition='auto',
593
  marker_color='rgb(158,202,225)',
594
  opacity=0.8
@@ -605,9 +607,9 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
605
  xaxis_title='Space ID',
606
  yaxis_title='Rank',
607
  yaxis=dict(
608
- ticktext=[str(i) for i in range(1, 301, 20)], # 1๋ถ€ํ„ฐ 300๊นŒ์ง€ 20 ๊ฐ„๊ฒฉ
609
- tickvals=[301 - i for i in range(1, 301, 20)], # ๋ฐ˜์ „๋œ ๊ฐ’
610
- range=[0, 300] # y์ถ• ๋ฒ”์œ„ ์„ค์ •
611
  ),
612
  height=800,
613
  showlegend=False,
@@ -629,7 +631,10 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
629
  rank = space.get('rank', 'N/A')
630
  likes = space.get('likes', 0)
631
  title = space.get('title', 'No Title')
632
- description = space.get('description', 'No Description')[:100]
 
 
 
633
 
634
  html_content += f"""
635
  <div style='
@@ -640,9 +645,9 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
640
  transition: transform 0.2s;
641
  '>
642
  <h3 style='color: #34495e;'>Rank #{rank} - {space_id}</h3>
643
- <p style='color: #7f8c8d;'>๐Ÿ‘ Likes: {likes}</p>
644
- <p style='color: #2c3e50;'>{title}</p>
645
- <p style='color: #7f8c8d; font-size: 0.9em;'>{description}...</p>
646
  <a href='{target_spaces[space_id]}'
647
  target='_blank'
648
  style='
@@ -665,8 +670,9 @@ def get_spaces_data(sort_type="trending", progress=gr.Progress()):
665
  df = pd.DataFrame([{
666
  'Rank': space.get('rank', 'N/A'),
667
  'Space ID': space.get('id', ''),
668
- 'Likes': space.get('likes', 'N/A'),
669
  'Title': space.get('title', 'N/A'),
 
 
670
  'URL': target_spaces[space.get('id', '')]
671
  } for space in spaces])
672
 
 
550
  }
551
 
552
  if sort_type == "modes":
553
+ params['sort'] = 'likes'
554
 
555
  try:
556
  progress(0, desc=f"Fetching {sort_type} spaces data...")
 
580
  ids = [space['id'] for space in spaces]
581
  ranks = [space['rank'] for space in spaces]
582
  likes = [space.get('likes', 0) for space in spaces]
583
+ titles = [space.get('title', 'No Title') for space in spaces]
584
 
585
+ # Y์ถ• ๊ฐ’์„ ๋ฐ˜์ „
586
+ y_values = [301 - r for r in ranks]
587
 
588
  # ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
589
  fig.add_trace(go.Bar(
590
  x=ids,
591
  y=y_values,
592
+ text=[f"Rank: {r}<br>Title: {t}<br>Likes: {l}"
593
+ for r, t, l in zip(ranks, titles, likes)],
594
  textposition='auto',
595
  marker_color='rgb(158,202,225)',
596
  opacity=0.8
 
607
  xaxis_title='Space ID',
608
  yaxis_title='Rank',
609
  yaxis=dict(
610
+ ticktext=[str(i) for i in range(1, 301, 20)],
611
+ tickvals=[301 - i for i in range(1, 301, 20)],
612
+ range=[0, 300]
613
  ),
614
  height=800,
615
  showlegend=False,
 
631
  rank = space.get('rank', 'N/A')
632
  likes = space.get('likes', 0)
633
  title = space.get('title', 'No Title')
634
+ description = space.get('description', 'No Description')
635
+
636
+ # description์ด ๋„ˆ๋ฌด ๊ธธ๋ฉด ์ž๋ฅด๊ธฐ
637
+ short_description = description[:150] + '...' if description and len(description) > 150 else description
638
 
639
  html_content += f"""
640
  <div style='
 
645
  transition: transform 0.2s;
646
  '>
647
  <h3 style='color: #34495e;'>Rank #{rank} - {space_id}</h3>
648
+ <h4 style='color: #2c3e50; margin: 10px 0;'>{title}</h4>
649
+ <p style='color: #7f8c8d; margin-bottom: 10px;'>๐Ÿ‘ Likes: {likes}</p>
650
+ <p style='color: #7f8c8d; font-size: 0.9em; margin-bottom: 15px;'>{short_description}</p>
651
  <a href='{target_spaces[space_id]}'
652
  target='_blank'
653
  style='
 
670
  df = pd.DataFrame([{
671
  'Rank': space.get('rank', 'N/A'),
672
  'Space ID': space.get('id', ''),
 
673
  'Title': space.get('title', 'N/A'),
674
+ 'Description': space.get('description', 'N/A')[:100] + '...',
675
+ 'Likes': space.get('likes', 'N/A'),
676
  'URL': target_spaces[space.get('id', '')]
677
  } for space in spaces])
678