Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions comprl/src/comprl/scripts/reset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""script to reset the game database and the mu and sigma in the user database"""
"""Reset user scores and delete all games from the database."""

from comprl.server.data import UserData, GameData, init_engine
import logging
Expand All @@ -20,15 +20,14 @@
def reset_games():
"""deletes the game table"""
GameData.delete_all()
logging.info("The games table has been deleted.")
logging.info("Cleared games table.")


def reset_elo():
"""reset the elo in the user database: set mu=25.000 and sigma=8.333"""
"""Reset the mu/sigma score of all users to default values"""
UserData.reset_all_ratings()
logging.info(
"The matchmaking parameters have been reset to default values for all users."
)
logging.info("Reset matchmaking parameters to default values.")
logging.info("Cleared rating change log.")


if __name__ == "__main__":
Expand Down Expand Up @@ -64,7 +63,7 @@ def reset_elo():

user_answer = input(
"Are you sure you want to delete the games table and "
"reset the matchmaking parameters? (Y/N)"
"reset the matchmaking parameters? (Y/n) "
)

if user_answer.lower() == "y":
Expand Down
1 change: 1 addition & 0 deletions comprl/src/comprl/server/data/sql_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def reset_all_ratings() -> None:
"""Resets the matchmaking parameters of all users."""
with get_session() as session:
session.query(User).update({"mu": DEFAULT_MU, "sigma": DEFAULT_SIGMA})
session.query(RatingChangeLog).delete()
session.commit()

@staticmethod
Expand Down