services.stats_service module
Statistics Service for Django Integration
This service handles saving Discord message statistics to the Django database. It provides an interface between the Discord bot and the Django web application.
- class services.stats_service.StatsService[source]
Bases:
object
Service for managing user statistics data with Django integration.
- save_statistics_to_django(stats_data, job_id=None)[source]
Save collected statistics to Django database.
- async save_statistics_to_django_async(stats_data, job_id=None)[source]
Async version of save_statistics_to_django for use in Discord bot context.
- Return type:
- create_collection_job(guild_id, guild_name, target_user_id=None, target_username=None, time_range_days=None)[source]
Create a statistics collection job in Django.
- Returns:
Job ID if successful, None otherwise
- Return type:
- save_message_statistics_streaming(guild_id, guild_name, channel_id, channel_name, user_id, username, avatar_url='', message_timestamp=None)[source]
Save a single message’s statistics incrementally to reduce memory usage.
- Parameters:
guild_id (
int
) – Discord guild IDguild_name (
str
) – Guild namechannel_id (
int
) – Discord channel IDchannel_name (
str
) – Channel nameuser_id (
int
) – Discord user IDusername (
str
) – User’s display nameavatar_url (
str
) – User’s avatar URLmessage_timestamp (
datetime
) – When the message was created
- Returns:
True if saved successfully
- Return type: