app.repository.dashboard_repository module¶
- class app.repository.dashboard_repository.DashboardRepository(session_factory, model_games=<class 'app.model.games.Games'>, model_tasks=<class 'app.model.tasks.Tasks'>, model_users=<class 'app.model.users.Users'>, model_logs=<class 'app.model.logs.Logs'>, model_user_points=<class 'app.model.user_points.UserPoints'>, model_user_actions=<class 'app.model.user_actions.UserActions'>)[source]¶
Bases:
BaseRepositoryRepository class for API keys and dashboard metrics.
- Parameters:
session_factory (Callable[[...], AbstractAsyncContextManager[AsyncSession]])
- __init__(session_factory, model_games=<class 'app.model.games.Games'>, model_tasks=<class 'app.model.tasks.Tasks'>, model_users=<class 'app.model.users.Users'>, model_logs=<class 'app.model.logs.Logs'>, model_user_points=<class 'app.model.user_points.UserPoints'>, model_user_actions=<class 'app.model.user_actions.UserActions'>)[source]¶
Initializes the DashboardRepository with the provided session factory and models.
- Parameters:
session_factory (Callable[[...], AbstractAsyncContextManager[AsyncSession]])
- Return type:
None
- process_query(query, model=None, start_date=None, end_date=None, group_by_column=None)[source]¶
Processes the SELECT statement by filtering and grouping the results.
The date filter is applied to the
created_atcolumn of the model actually being aggregated (model); it previously always filteredmodel_users.created_at, which cross-joinedUsersinto queries overGames/Logs/UserPoints/UserActionsand skewed their counts.modeldefaults tomodel_usersto preserve the users-summary behaviour when a caller omits it.
- async get_dashboard_summary(start_date, end_date, group_by)[source]¶
Retrieves the dashboard summary.
- Parameters:
start_date – The start date for the summary.
end_date – The end date for the summary.
group_by – The group by for the summary (e.g. day, week, month).
- Returns:
Dict[str, Any] – The dashboard summary.
- async get_dashboard_summary_logs(start_date, end_date, group_by)[source]¶
Retrieves the dashboard summary logs.
- Parameters:
start_date – The start date for the summary.
end_date – The end date for the summary.
group_by – The group by for the summary (e.g. day, week, month).
- Returns:
Dict[str, Any] – The dashboard summary logs.