afght12 commited on
Commit
0a06d22
ยท
verified ยท
1 Parent(s): d8378d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -8
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
- return leaderboard_data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- outputs=leaderboard_table)
204
 
205
  # Initial load of leaderboard data
206
- demo.load(update_leaderboard_table, inputs=None, outputs=leaderboard_table)
 
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()