Ricercar commited on
Commit
3fe6653
1 Parent(s): bca72f3

database fix

Browse files
Files changed (1) hide show
  1. pages/Gallery.py +15 -13
pages/Gallery.py CHANGED
@@ -459,22 +459,24 @@ class GalleryApp:
459
  st.session_state.gallery_state = 'graph'
460
 
461
  print('selected_dict: ', st.session_state.selected_dict)
462
-
463
- # # save the user selection to database
464
  cursor = GALLERY_CONN.cursor()
465
- st.session_state.epoch['gallery'] += 1
466
- checkouttime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
467
- # for modelVersion_id in st.session_state.selected_dict[prompt_id]:
468
- for key, values in st.session_state.selected_dict.items():
469
- # print('key: ', key, 'values: ', values)
470
- key_tag = self.promptBook[self.promptBook['prompt_id'] == key]['tag'].unique()[0]
471
- for value in values:
472
- query = "INSERT INTO gallery_selections (username, timestamp, tag, prompt_id, modelVersion_id, checkouttime, epoch) VALUES ('{}', '{}', '{}', '{}', {}, '{}', {})".format(st.session_state.user_id[0], st.session_state.user_id[1], key_tag, key, value, checkouttime, st.session_state.epoch['gallery'])
473
- print(query)
474
- cursor.execute(query)
475
- GALLERY_CONN.commit()
476
  cursor.close()
477
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
  # get the largest epoch number of this user and prompt
479
  cursor = GALLERY_CONN.cursor()
480
  db_table = 'battle_results' if st.session_state.assigned_rank_mode=='Battle' else 'sort_results'
 
459
  st.session_state.gallery_state = 'graph'
460
 
461
  print('selected_dict: ', st.session_state.selected_dict)
 
 
462
  cursor = GALLERY_CONN.cursor()
 
 
 
 
 
 
 
 
 
 
 
463
  cursor.close()
464
 
465
+ # # save the user selection to database
466
+ # cursor = GALLERY_CONN.cursor()
467
+ # st.session_state.epoch['gallery'] += 1
468
+ # checkouttime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
469
+ # # for modelVersion_id in st.session_state.selected_dict[prompt_id]:
470
+ # for key, values in st.session_state.selected_dict.items():
471
+ # # print('key: ', key, 'values: ', values)
472
+ # key_tag = self.promptBook[self.promptBook['prompt_id'] == key]['tag'].unique()[0]
473
+ # for value in values:
474
+ # query = "INSERT INTO gallery_selections (username, timestamp, tag, prompt_id, modelVersion_id, checkouttime, epoch) VALUES ('{}', '{}', '{}', '{}', {}, '{}', {})".format(st.session_state.user_id[0], st.session_state.user_id[1], key_tag, key, value, checkouttime, st.session_state.epoch['gallery'])
475
+ # print(query)
476
+ # cursor.execute(query)
477
+ # GALLERY_CONN.commit()
478
+ # cursor.close()
479
+
480
  # get the largest epoch number of this user and prompt
481
  cursor = GALLERY_CONN.cursor()
482
  db_table = 'battle_results' if st.session_state.assigned_rank_mode=='Battle' else 'sort_results'