Ricercar commited on
Commit
5a4cc78
1 Parent(s): 67b2625

connect summary to database

Browse files
Files changed (1) hide show
  1. pages/Summary.py +11 -0
pages/Summary.py CHANGED
@@ -191,6 +191,17 @@ class DashboardApp:
191
  # st.session_state.modelVersion_standings[tag][current], st.session_state.modelVersion_standings[tag][target] = st.session_state.modelVersion_standings[tag][target], st.session_state.modelVersion_standings[tag][current]
192
  # insert the current before the target
193
  st.session_state.modelVersion_standings[tag].insert(target, st.session_state.modelVersion_standings[tag].pop(current))
 
 
 
 
 
 
 
 
 
 
 
194
 
195
  def score_calculator(self, results, db_table):
196
  modelVersion_standings = {}
 
191
  # st.session_state.modelVersion_standings[tag][current], st.session_state.modelVersion_standings[tag][target] = st.session_state.modelVersion_standings[tag][target], st.session_state.modelVersion_standings[tag][current]
192
  # insert the current before the target
193
  st.session_state.modelVersion_standings[tag].insert(target, st.session_state.modelVersion_standings[tag].pop(current))
194
+ # print(st.session_state.modelVersion_standings[tag])
195
+ # curser = RANKING_CONN.cursor()
196
+ # RANKING_CONN.commit()
197
+ # curser.close()
198
+ curser = RANKING_CONN.cursor()
199
+ # clear the current user's ranking results
200
+ curser.execute(f"DELETE FROM summary_results WHERE username = '{st.session_state.user_id[0]}' AND timestamp = '{st.session_state.user_id[1]}' AND tag = '{tag}'")
201
+ for i in range(len(st.session_state.modelVersion_standings[tag])):
202
+ curser.execute(f"INSERT INTO summary_results (username, timestamp, tag, modelVersion_id, position, ranking_score) VALUES ('{st.session_state.user_id[0]}', '{st.session_state.user_id[1]}', '{tag}', '{st.session_state.modelVersion_standings[tag][i][0]}', {i+1}, {st.session_state.modelVersion_standings[tag][i][1]})")
203
+ RANKING_CONN.commit()
204
+ curser.close()
205
 
206
  def score_calculator(self, results, db_table):
207
  modelVersion_standings = {}