Fix parsing tweaks

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-04-06 19:16:32 +02:00
parent 78a43148a8
commit aac4fc59e6
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 8 additions and 0 deletions

View File

@ -607,12 +607,20 @@ class Tournament(models.Model):
worksheet.client.batch_update(spreadsheet.id, body) worksheet.client.batch_update(spreadsheet.id, body)
def parse_tweaks_spreadskeets(self): def parse_tweaks_spreadskeets(self):
if not self.pools.exists():
# Draw has not been done yet
return
gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT) gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT)
spreadsheet = gc.open_by_key(self.notes_sheet_id) spreadsheet = gc.open_by_key(self.notes_sheet_id)
worksheet = spreadsheet.worksheet("Classement final") worksheet = spreadsheet.worksheet("Classement final")
score_cell = worksheet.find("Score") score_cell = worksheet.find("Score")
max_row = score_cell.row - 3 max_row = score_cell.row - 3
if max_row == 1:
# There is no team
return
data = worksheet.get_values(f"A2:E{max_row}") data = worksheet.get_values(f"A2:E{max_row}")
for line in data: for line in data:
trigram = line[0][-4:-1] trigram = line[0][-4:-1]