ouhenio commited on
Commit
02a0634
·
verified ·
1 Parent(s): 0e99050

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -2
app.py CHANGED
@@ -95,6 +95,22 @@ countries = {
95
  }
96
  }
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  @lru_cache(maxsize=32)
99
  def get_user_contributions_cached(cache_buster: int):
100
  return get_user_contributions()
@@ -141,12 +157,23 @@ def get_user_contributions():
141
  except Exception as e:
142
  print(f"Error processing dataset {dataset_name}: {e}")
143
 
 
 
144
  rows = []
145
  for user_id, data in user_contributions.items():
 
 
 
 
 
 
 
 
146
  row = {
147
- "Username": data["username"],
148
  "Total": data["contributions"],
149
- "Blend-es": data["contributions"]
 
150
  }
151
  rows.append(row)
152
 
 
95
  }
96
  }
97
 
98
+ def load_include_data():
99
+ try:
100
+ if os.path.exists("include.csv"):
101
+ include_df = pd.read_csv("include.csv")
102
+ if "Nombre en Discord / username" in include_df.columns and "Número de preguntas / number of questions" in include_df.columns:
103
+ include_dict = {}
104
+ for _, row in include_df.iterrows():
105
+ username = row["Nombre en Discord / username"]
106
+ questions = row["Número de preguntas / number of questions"]
107
+ if pd.notna(username) and pd.notna(questions):
108
+ include_dict[username.lower()] = int(questions)
109
+ return include_dict
110
+ except Exception as e:
111
+ print(f"Error loading include.csv: {e}")
112
+ return {}
113
+
114
  @lru_cache(maxsize=32)
115
  def get_user_contributions_cached(cache_buster: int):
116
  return get_user_contributions()
 
157
  except Exception as e:
158
  print(f"Error processing dataset {dataset_name}: {e}")
159
 
160
+ include_data = load_include_data()
161
+
162
  rows = []
163
  for user_id, data in user_contributions.items():
164
+ username = data["username"]
165
+ include_value = 0
166
+
167
+ for discord_name, questions in include_data.items():
168
+ if username.lower() in discord_name.lower() or discord_name.lower() in username.lower():
169
+ include_value = questions
170
+ break
171
+
172
  row = {
173
+ "Username": username,
174
  "Total": data["contributions"],
175
+ "Blend-es": data["contributions"],
176
+ "INCLUDE": include_value
177
  }
178
  rows.append(row)
179