Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,6 @@ from communex.client import CommuneClient
|
|
10 |
|
11 |
FONT = """<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap" rel="stylesheet">"""
|
12 |
|
13 |
-
TITLE = """<h1 align="center" id="space-title" class="typewriter">Synthia Leaderboard</h1>"""
|
14 |
-
|
15 |
IMAGE = """<p align="center" style="font-size: 72px;">๐๐๐๐๐
๐๐</p>"""
|
16 |
|
17 |
HEADER = """
|
@@ -117,7 +115,21 @@ async def update_leaderboard_table():
|
|
117 |
# Add emojis to the leaderboard data
|
118 |
for row in leaderboard_data:
|
119 |
row[0] = f"{row[0]} ๐"
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
|
123 |
stone_gray = Color(
|
@@ -184,12 +196,21 @@ seafoam = Seafoam()
|
|
184 |
|
185 |
with gr.Blocks(theme=seafoam, analytics_enabled=True) as demo:
|
186 |
gr.HTML(FONT)
|
187 |
-
gr.HTML(TITLE)
|
188 |
gr.HTML(IMAGE)
|
189 |
gr.HTML(HEADER)
|
190 |
gr.HTML(EVALUATION_HEADER)
|
191 |
gr.HTML(EVALUATION_DETAILS)
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
leaderboard_table = gr.components.Dataframe(
|
194 |
headers=["Rank ๐", "UID", "Name", "Rewards / Day", "$USD Value"],
|
195 |
datatype=["str", "str", "str"],
|
@@ -197,13 +218,13 @@ with gr.Blocks(theme=seafoam, analytics_enabled=True) as demo:
|
|
197 |
visible=True,
|
198 |
elem_id="leaderboard-table",
|
199 |
)
|
200 |
-
|
201 |
refresh_button = gr.Button("Refresh Leaderboard")
|
202 |
-
refresh_button.click(fn=update_leaderboard_table,
|
203 |
-
|
204 |
|
205 |
# Initial load of leaderboard data
|
206 |
-
demo.load(update_leaderboard_table, inputs=None, outputs=
|
|
|
207 |
|
208 |
if __name__ == "__main__":
|
209 |
demo.launch()
|
|
|
10 |
|
11 |
FONT = """<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap" rel="stylesheet">"""
|
12 |
|
|
|
|
|
13 |
IMAGE = """<p align="center" style="font-size: 72px;">๐๐๐๐๐
๐๐</p>"""
|
14 |
|
15 |
HEADER = """
|
|
|
115 |
# Add emojis to the leaderboard data
|
116 |
for row in leaderboard_data:
|
117 |
row[0] = f"{row[0]} ๐"
|
118 |
+
|
119 |
+
# Calculate the total USD value
|
120 |
+
total_usd_value = sum(float(row[4][1:]) for row in leaderboard_data)
|
121 |
+
|
122 |
+
# Calculate rewards per week and per month
|
123 |
+
rewards_per_week = total_usd_value * 7
|
124 |
+
rewards_per_month = total_usd_value * 30
|
125 |
+
|
126 |
+
return leaderboard_data, f'''
|
127 |
+
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: bold;">
|
128 |
+
<div>๐๐ค๐ฉ๐๐ก ๐๐๐ฟ ๐๐๐ฌ๐๐ง๐๐จ ๐๐๐ง ๐๐๐๐ : ${rewards_per_week:,.2f}</div>
|
129 |
+
<div>๐๐ค๐ฉ๐๐ก ๐๐๐ฟ ๐๐๐ฌ๐๐ง๐๐จ ๐๐๐ง ๐ฟ๐๐ฎ: ${total_usd_value:,.2f}</div>
|
130 |
+
<div>๐๐ค๐ฉ๐๐ก ๐๐๐ฟ ๐๐๐ฌ๐๐ง๐๐จ ๐๐๐ง ๐๐ค๐ฃ๐ฉ๐: ${rewards_per_month:,.2f}</div>
|
131 |
+
</div>
|
132 |
+
'''
|
133 |
|
134 |
|
135 |
stone_gray = Color(
|
|
|
196 |
|
197 |
with gr.Blocks(theme=seafoam, analytics_enabled=True) as demo:
|
198 |
gr.HTML(FONT)
|
|
|
199 |
gr.HTML(IMAGE)
|
200 |
gr.HTML(HEADER)
|
201 |
gr.HTML(EVALUATION_HEADER)
|
202 |
gr.HTML(EVALUATION_DETAILS)
|
203 |
|
204 |
+
total_usd_value_html = gr.HTML(
|
205 |
+
elem_id="total-usd-value",
|
206 |
+
value='''
|
207 |
+
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: bold;">
|
208 |
+
<div>๐๐ค๐ฉ๐๐ก ๐๐๐ฟ ๐๐๐ฌ๐๐ง๐๐จ ๐๐๐ง ๐๐๐๐ : $0.00</div>
|
209 |
+
<div>๐๐ค๐ฉ๐๐ก ๐๐๐ฟ ๐๐๐ฌ๐๐ง๐๐จ ๐๐๐ง ๐ฟ๐๐ฎ: $0.00</div>
|
210 |
+
<div>๐๐ค๐ฉ๐๐ก ๐๐๐ฟ ๐๐๐ฌ๐๐ง๐๐จ ๐๐๐ง ๐๐ค๐ฃ๐ฉ๐: $0.00</div>
|
211 |
+
</div>
|
212 |
+
'''
|
213 |
+
)
|
214 |
leaderboard_table = gr.components.Dataframe(
|
215 |
headers=["Rank ๐", "UID", "Name", "Rewards / Day", "$USD Value"],
|
216 |
datatype=["str", "str", "str"],
|
|
|
218 |
visible=True,
|
219 |
elem_id="leaderboard-table",
|
220 |
)
|
|
|
221 |
refresh_button = gr.Button("Refresh Leaderboard")
|
222 |
+
refresh_button.click(fn=update_leaderboard_table, outputs=[
|
223 |
+
leaderboard_table, total_usd_value_html])
|
224 |
|
225 |
# Initial load of leaderboard data
|
226 |
+
demo.load(update_leaderboard_table, inputs=None, outputs=[
|
227 |
+
leaderboard_table, total_usd_value_html])
|
228 |
|
229 |
if __name__ == "__main__":
|
230 |
demo.launch()
|