Compare commits

...

4 Commits

Author SHA1 Message Date
Emmy D'Anello ceedd0678c
Sleep more in parsing notation sheets to avoid reaching the API limit
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-06 10:49:19 +02:00
Emmy D'Anello d13385fa01
Don't set notes if there isn't anyone
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-06 10:42:55 +02:00
Emmy D'Anello 8996fc2cca
Fix updating Google Spreadsheet after uploading CSV
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-06 10:39:08 +02:00
Emmy D'Anello 65dcc978c1
Don't parse spreadsheet if there is no spreadsheet
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-06 10:38:09 +02:00
3 changed files with 10 additions and 3 deletions

View File

@ -26,6 +26,12 @@ class Command(BaseCommand):
if options['verbosity'] >= 1:
self.stdout.write(f"Parsing notation sheet for {tournament}")
if not tournament.notes_sheet_id:
if options['verbosity'] >= 1:
self.stdout.write(
self.style.WARNING(f"No spreadsheet found for {tournament}. Please create it first"))
continue
pools = tournament.pools.all()
if options['round']:
pools = pools.filter(round=options['round'])
@ -35,7 +41,6 @@ class Command(BaseCommand):
if options['verbosity'] >= 1:
self.stdout.write(f"Parsing notation sheet for pool {pool.short_name} for {tournament}")
pool.parse_spreadsheet()
sleep(3) # Three calls = 3s sleep
tournament.parse_tweaks_spreadskeets()
sleep(1)

View File

@ -1327,6 +1327,8 @@ class Pool(models.Model):
for i, passage in enumerate(self.passages.all()):
note = passage.notes.get(jury=jury)
note_line = line[2 + i * passage_width:2 + (i + 1) * passage_width]
if not note_line: # There is no note
continue
note.set_all(*note_line)
note.save()

View File

@ -1182,7 +1182,7 @@ class PoolUploadNotesView(VolunteerMixin, FormView, DetailView):
note.save()
if os.getenv('GOOGLE_PRIVATE_KEY_ID', None):
pool.update_notes_spreadsheet()
pool.update_spreadsheet()
messages.success(self.request, _("Notes were successfully uploaded."))
return super().form_valid(form)