Spaces:
Sleeping
Sleeping
only reset non-empty ratings
Browse files
app.ipynb
CHANGED
@@ -207,15 +207,16 @@
|
|
207 |
" except:\n",
|
208 |
" gr.Warning(f'Could not save the task demo_task_{task_id} to the spreadsheet :(')\n",
|
209 |
"\n",
|
210 |
-
" def reset_gsheet(self,
|
211 |
" \"\"\"Reset the task ratings in google spreadsheet.\"\"\"\n",
|
212 |
" try:\n",
|
213 |
" # configure gsheet credentials\n",
|
214 |
" gc = gspread.service_account('./gsheet_service_account.json')\n",
|
215 |
" sheet_id = '1D2sfE9YXKtd7cKlgalo5UnuNKC-GhxlGqHVYUlkQlCY'\n",
|
216 |
" sh = gc.open_by_key(sheet_id).worksheet('demo-app')\n",
|
217 |
-
" # update task ratings in the worksheet\n",
|
218 |
-
" sh.
|
|
|
219 |
" except:\n",
|
220 |
" gr.Warning(f'Could not reset the task demo_task_{task_id} in the spreadsheet :(')\n",
|
221 |
"\n",
|
|
|
207 |
" except:\n",
|
208 |
" gr.Warning(f'Could not save the task demo_task_{task_id} to the spreadsheet :(')\n",
|
209 |
"\n",
|
210 |
+
" def reset_gsheet(self, task_id):\n",
|
211 |
" \"\"\"Reset the task ratings in google spreadsheet.\"\"\"\n",
|
212 |
" try:\n",
|
213 |
" # configure gsheet credentials\n",
|
214 |
" gc = gspread.service_account('./gsheet_service_account.json')\n",
|
215 |
" sheet_id = '1D2sfE9YXKtd7cKlgalo5UnuNKC-GhxlGqHVYUlkQlCY'\n",
|
216 |
" sh = gc.open_by_key(sheet_id).worksheet('demo-app')\n",
|
217 |
+
" # update task ratings in the worksheet if there are any (clearing empty values removes formatting)\n",
|
218 |
+
" if sh.get(f'C{3+int(task_id)}:J{3+int(task_id)}')[0]:\n",
|
219 |
+
" sh.batch_clear([f'C{3+int(task_id)}:J{3+int(task_id)}'])\n",
|
220 |
" except:\n",
|
221 |
" gr.Warning(f'Could not reset the task demo_task_{task_id} in the spreadsheet :(')\n",
|
222 |
"\n",
|