db laoder fixes

This commit is contained in:
2022-06-06 08:30:16 -05:00
parent 98a9e2012a
commit c4a1387460
2 changed files with 8 additions and 3 deletions

View File

@@ -109,7 +109,12 @@ def _save_db_scores(wordle_day: wordlinator.utils.WordleDay, scores: dict):
to_update.append(db_score)
else:
hole = [h for h in db_holes if h.hole == day][0]
hole_match = [h for h in db_holes if h.hole == day]
if hole_match:
hole = hole_match[0]
else:
hole = db.get_or_create_hole(game_no, day)
db_holes.append(hole)
to_create.append(
{
"score": score_entry,

View File

@@ -81,7 +81,7 @@ class WordleDb:
def get_holes(self, round_no):
round = self.get_or_create_round(round_no)
return Hole.select().filter(game_id=round.game_id)
return list(Hole.select().filter(game_id=round.game_id))
def create_round_holes(self, round_no):
for hole_no in range(1, 19):
@@ -115,7 +115,7 @@ class WordleDb:
def get_scores(self, round_no):
round = self.get_or_create_round(round_no)
return Score.select().filter(Score.game_id == round.game_id)
return list(Score.select().filter(Score.game_id == round.game_id))
def bulk_insert_scores(self, scores: typing.List[typing.Dict]):
with db.atomic():