Skip to content

Commit

Permalink
fix: Algo scores fix only for default levels
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 committed Feb 28, 2024
1 parent 4deb458 commit c87bf7f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
14 changes: 10 additions & 4 deletions game/migrations/0090_add_missing_model_solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ def add_missing_model_solutions(apps: Apps, *args):
}

for level_name, model_solution in model_solutions.items():
count = Level.objects.filter(name=level_name).update(
model_solution=model_solution, disable_algorithm_score=False
)
count = Level.objects.filter(
default=True, episode__isnull=False, name=level_name
).update(model_solution=model_solution, disable_algorithm_score=False)
assert count == 1

Attempt = apps.get_model("game", "Attempt")

attempts = Attempt.objects.filter(
level__default=True,
level__episode__isnull=False,
level__name__in=[
"80",
"81",
Expand Down Expand Up @@ -75,6 +77,8 @@ def remove_new_model_solutions(apps: Apps, *args):
Level = apps.get_model("game", "Level")

Level.objects.filter(
default=True,
episode__isnull=False,
name__in=[
"80",
"81",
Expand All @@ -88,12 +92,14 @@ def remove_new_model_solutions(apps: Apps, *args):
"89",
"90",
"91",
]
],
).update(model_solution="[]", disable_algorithm_score=True)

Attempt = apps.get_model("game", "Attempt")

Attempt.objects.filter(
level__default=True,
level__episode__isnull=False,
level__name__in=[
"80",
"81",
Expand Down
22 changes: 14 additions & 8 deletions game/migrations/0091_disable_algo_score_if_no_model_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@
def disable_algo_score_for_levels_without_model_solution(apps: Apps, *args):
Level = apps.get_model("game", "Level")

Level.objects.filter(default=True, model_solution="[]").update(
disable_algorithm_score=True
)
Level.objects.filter(
default=True, episode__isnull=False, model_solution="[]"
).update(disable_algorithm_score=True)

Attempt = apps.get_model("game", "Attempt")

Attempt.objects.filter(
level__default=True, level__model_solution="[]", score=20
level__default=True,
level__episode__isnull=False,
level__model_solution="[]",
score=20,
).update(score=10)


def enable_algo_score_for_levels_without_model_solution(apps: Apps, *args):
Level = apps.get_model("game", "Level")

Level.objects.filter(default=True, model_solution="[]").update(
disable_algorithm_score=False
)
Level.objects.filter(
default=True, episode__isnull=False, model_solution="[]"
).update(disable_algorithm_score=False)

Attempt = apps.get_model("game", "Attempt")

Attempt.objects.filter(
level__default=True, level__model_solution="[]", score=10
level__default=True,
level__episode__isnull=False,
level__model_solution="[]",
score=10,
).update(score=20)


Expand Down

0 comments on commit c87bf7f

Please sign in to comment.