Spaces:
Running
Running
Update app.py
Browse files
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'
|
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์ถ ๊ฐ์ ๋ฐ์
|
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}"
|
|
|
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)],
|
609 |
-
tickvals=[301 - i for i in range(1, 301, 20)],
|
610 |
-
range=[0, 300]
|
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')
|
|
|
|
|
|
|
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 |
-
<
|
644 |
-
<p style='color: #
|
645 |
-
<p style='color: #7f8c8d; font-size: 0.9em;'>{
|
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 |
|