Database#
functions#
All database related functions are here.
- class src.db.ReactionStatus(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Enum for reaction status
- class src.db.GameStatus(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Enum for game status
- property icon#
Status assignment icon
- class src.db.Base(**kwargs)[source]#
Declarative base class
- Parameters:
DeclarativeBase (_type_) – Basic class that is inherited
-
metadata:
ClassVar[MetaData]
= MetaData()# Refers to the
_schema.MetaData
collection that will be used for new_schema.Table
objects.See also
-
registry:
ClassVar[_RegistryType]
= <sqlalchemy.orm.decl_api.registry object># Refers to the
_orm.registry
in use where new_orm.Mapper
objects will be associated.
- class src.db.GamePlayerAssociation(**kwargs)[source]#
_summary_
- Parameters:
Base (_type_) – _description_
- class src.db.League(**kwargs)[source]#
League table
- Parameters:
Base (_type_) – Basic class that is inherited
- class src.db.Rank(**kwargs)[source]#
List of ranks for each player per game
- Parameters:
Base (_type_) – Basic class that is inherited
- class src.db.Game(**kwargs)[source]#
Game table
- Parameters:
Base (_type_) – Basic class that is inherited
- class src.db.Game1PlayerResult(**kwargs)[source]#
Class table for game 1.
- Parameters:
Base (_type_) – Basic class that is inherited
- class src.db.Exercise(**kwargs)[source]#
Exercise table
- Parameters:
Base (_type_) – Basic class that is inherited
- class src.db.Quest(**kwargs)[source]#
Quests table
- Parameters:
Base (_type_) – Basic class that is inherited
- class src.db.Task(**kwargs)[source]#
Task table
- Parameters:
Base (_type_) – Basic class that is inherited
- class src.db.Reaction(**kwargs)[source]#
Reaction table
- Parameters:
Base (_type_) – Basic class that is inherited
- async src.db.get_player(config, player_id)[source]#
Function to get a player from the database by dc_id
- async src.db.get_game_from_id(config, game_id)[source]#
Function to get a game from the database by id
- async src.db.process_player(config, player_list)[source]#
Function to process a player list and add them to the database if they are not already there. Also update the hours of a player if there are new values.
- async src.db.create_game(config, game_name, player)[source]#
Function to create a game in the database and link all players to the game.
- async src.db.get_game_player_association(config, game_id, player_id)[source]#
Funktion to get a game player association from the database by game id and player id.
- Parameters:
- Returns:
Object of the game player association or None if not found
- Return type:
GamePlayerAssociation | None
- async src.db.get_games_w_status(config, status)[source]#
This function get all changeable games back. Games that have the status CREATED, RUNNING or PAUSED can be changed.
- async src.db.get_random_tasks(config, limit, rating_min=0, rating_max=101)[source]#
This function gets a list of random tasks from the database. The number of tasks is limited by the limit parameter.
- async src.db.get_main_task(config)[source]#
Funktion to get a random main task from the database for game 1
- Parameters:
config (Configuration) – App configuration
- Returns:
main task
- Return type:
- async src.db.get_tasks_based_on_rating_1(config, rating)[source]#
This function gets a list of tasks from the database based on the rating for game 1. The rating is used to filter the tasks.
- async src.db.get_tasks_sort_hard(tasks, number_of_tasks=5)[source]#
Get the top tasks based on their rating sorted by hardness (highest rating first).
- async src.db.get_tasks_sort_soft(tasks, number_of_tasks=5)[source]#
Get the top tasks based on their rating sorted by hardness (lowest rating first).
- async src.db.balanced_task_mix(tasks, number_of_tasks=5)[source]#
This function creates a balanced task mix from the list of tasks. The tasks are sorted by rating and the list is divided into equal parts. There is one task from each of the different difficulty levels.
- async src.db.balanced_task_mix_random(config, tasks, exclude_ids)[source]#
This function creates a balanced random task mix from the list of tasks. The tasks are sorted by rating and the list is divided into equal parts. There is one task from each of the different difficulty levels.
- async src.db.get_all_game_x_player_from_message_id(config, message_id)[source]#
Function get all games based on message_id with join off all players in the game.
- async src.db.get_all_db_obj_from_id(config, obj, ids)[source]#
Function returns all objects from database based on given IDs from handed over object class.
- async src.db.update_db_obj(config, obj)[source]#
Function to update a game or player object in the database
- async src.db.update_db_objs(config, objs)[source]#
Function to update a game or player object in the database
- async src.db.insert_db_obj(config, obj)[source]#
Fuction to insert a new handed over object into the database and return the object.
- async src.db.get_reaction_for_remove(config, message_id, user_id, emoji_name)[source]#
Get all reactions for a given message ID, user ID and emoji name.
- async src.db.set_reaction_status(config, reactions, status)[source]#
Set the status of a list of reactions to a given status.
- Parameters:
config (Configuration) – App configuration
reactions (list[Reaction]) – List of Reaction objects to update
status (ReactionStatus) – Status to set for the reactions
- Return type:
- async src.db.get_reaction(config, message_id, user_id, status)[source]#
Function to get all reactions for a given message ID, user ID and status.
- Parameters:
config (Configuration) – App configuration
message_id (int) – Message ID to search from DC
user_id (int) – Disscord user ID
status (ReactionStatus) – Status from reaction to search for
- Returns:
List of reactions or None if an error occurs
- Return type:
- async src.db.merging_calc_base_game_1(config, game_ids)[source]#
Function prepares the ranking for game 1 based on the game IDs. The ranking is based on the number of completed tasks, survival status and player days.
- Parameters:
- Returns:
List of Game1PlayerResult objects with determined ranks
- Return type:
- async src.db.schedule_new_league_table(config, sorted_players)[source]#
Function to create a new league table based on the sorted players. First the old league table is deleted and then the new one is created based on the sorted players with their points and survived games.