db laoder fixes
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user