davidlms commited on
Commit
b671dbb
·
verified ·
1 Parent(s): 6f2b708

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import datetime
3
  import pandas as pd
 
4
  import gradio as gr
5
  import argilla as rg
6
  import plotly.graph_objects as go
@@ -30,17 +31,15 @@ def get_progress(dataset) -> dict:
30
 
31
 
32
  def get_leaderboard(dataset) -> dict:
33
- user_annotations = {}
34
  for record in dataset.records:
35
- for response in record.responses:
36
- user = response.user_id
37
- retrieved_user = client.users(id=user)
38
- user = retrieved_user.username
39
- if user not in user_annotations:
40
- user_annotations[user] = 0
41
- user_annotations[user] += 1
42
- print(user_annotations)
43
- return user_annotations
44
 
45
 
46
  def create_gauge_chart(progress):
 
1
  import os
2
  import datetime
3
  import pandas as pd
4
+ from collections import Counter
5
  import gradio as gr
6
  import argilla as rg
7
  import plotly.graph_objects as go
 
31
 
32
 
33
  def get_leaderboard(dataset) -> dict:
34
+ contributions = {}
35
  for record in dataset.records:
36
+ if record.status == "completed" and record.responses:
37
+ responses_list = list(record.responses)
38
+ if responses_list:
39
+ first_response = responses_list[0]
40
+ if hasattr(first_response, "user_id"):
41
+ contributions[record.id] = client.users(id=first_response.user_id).username
42
+ return dict(Counter(contributions.values()))
 
 
43
 
44
 
45
  def create_gauge_chart(progress):