app.services.user_points_analytics_service module¶
Analytics service for user points.
Aggregations, temporal queries and metrics over user_points records.
Extracted from UserPointsService so CRUD/write paths and analytic queries
have separate, focused services.
These methods are thin pass-throughs over UserPointsRepository analytics
queries; they are consumed primarily by strategy engines (app/engine) to
compute rewards based on historical user behaviour.
- class app.services.user_points_analytics_service.UserPointsAnalyticsService(user_points_repository)[source]¶
Bases:
BaseService- Parameters:
user_points_repository (UserPointsRepository)
- async count_measurements_by_external_task_id(external_task_id)[source]¶
Count all points rows recorded for an external task.
- Return type:
Any
- async get_user_task_measurements_count(externalTaskId, externalUserId)[source]¶
Count a user’s awards on a given external task.
- Return type:
Any
- async get_user_task_measurements_count_the_last_seconds(externalTaskId, externalUserId, seconds)[source]¶
Count a user’s awards on a task within the last
seconds.- Return type:
Any
- async get_avg_time_between_tasks_by_user_and_game_task(externalGameId, externalTaskId, externalUserId)[source]¶
Average seconds between a user’s consecutive awards on a task (
-1with fewer than two awards).- Return type:
Any
- async get_avg_time_between_tasks_for_all_users(externalGameId, externalTaskId)[source]¶
Average seconds between consecutive awards on a task across all users (
-1with fewer than two awards).- Return type:
Any
- async get_last_window_time_diff(externalTaskId, externalUserId)[source]¶
Seconds between a user’s two most recent awards on a task.
- Return type:
Any
- async get_new_last_window_time_diff(externalTaskId, externalUserId, externalGameId)[source]¶
Seconds elapsed since a user’s most recent award on a task.
- Return type:
Any
- async get_user_task_measurements(externalTaskId, externalUserId)[source]¶
Return the ordered timestamps of a user’s awards on a task.
- Return type:
Any
- async count_personal_records_by_external_game_id(external_game_id, externalUserId)[source]¶
Count the number of records for a user in a game.
- Return type:
Any
- async user_has_record_before_in_externalTaskId_last_min(externalTaskId, externalUserId, minutes)[source]¶
Check if a user has a record in the task in the last minutes minutes.
- Return type:
Any