UEWBot / dipvis

Django-based visualiser for tournaments for the boardgame Diplomacy
GNU General Public License v3.0
7 stars 5 forks source link

Date of VDL 2022 in WDD changed #251

Closed UEWBot closed 1 year ago

UEWBot commented 1 year ago

At one point, the date was that of the start of the league, but it is now the date of the end of the league.

This causes exceptions when adding to player background because it uses PlayerTournamentRanking.get_or_create() and date is a mandatory attribute but not part of the uniqueness constraint. So we fail to find a matching row, but we also fail to save a new row.

I guess we need to be able update the date somehow.

It's not clear whether this is a one-off or whether this will happen for all leagues.

UEWBot commented 1 year ago

From a background perspective, it doesn't matter, because we don't really use the date. It would be good, though, to have the dates in the two databases match

UEWBot commented 1 year ago

The actual error: Failed to save PlayerGameResult player=John Jamieson, tournament_name=Virtual Diplomacy League 2021, game_name=R 3 B 2, power=England, position=6, date=2022-01-15 Traceback (most recent call last): File ".../site-packages/django/db/models/query.py", line 581, in get_or_create return self.get(**kwargs), False File ".../site-packages/django/db/models/query.py", line 435, in get raise self.model.DoesNotExist( tournament.players.PlayerGameResult.DoesNotExist: PlayerGameResult matching query does not exist. During handling of the above exception, another exception occurred: Traceback (most recent call last): File ".../site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "tournament_playergameresult_tournament_name_309c0729_uniq" DETAIL: Key (tournament_name, game_name, player_id, power_id)=(Virtual Diplomacy League 2021, R 3 B 2, 2, 2) already exists.