We need to be able to track how many messages were sent per day per users.
This will give us the following features:
Total messages
Average daily messages
Average monthly messages
Per user: Total message
Per user: Average daily message
Per user: Average monthly message
Users text/voice online tracking
Every time an user goes online: We track which time the user went online
Every time an user goes offline: We compute for how long he was online and stores it
This will give us the following features:
Average daily users
Average daily time spent by users on server
Average monthly time spent by users on server
Total time spent in voice chat for one user
Total time spent in voice chat for all users
Average activity time in voice chat per day
Average activity time in voice chat per month
Highest activity time in voice chats
Highest uptime (who has been online the longer)
Computations
Uptimes are computed for every users and the value of online time is set to the last check on some events:
All users: Bot get closed (optional) or every arbitrary periodic time (avoid big looses when users stays online very long)
All users: Stats are shown
One user: User status is updated (online to offline)
Bot uptime
When starting, bot will remember the time, when asking for uptime, it will simply give the difference with actual time. This will replace "Server 'age' (uptime)"
Corner cases
Queries "per day" should have one row per day even those without data that day
Entities
2 tables are required for TRACKING daily data:
VoiceActivity: One row per user: Gives latest datetime when user was seen online
TextActivity: One row per user: Gives latest datetime when user was seen online
1 table is required for HISTORICAL past days data:
DailyResume: Stores one users ID, date, time voice online, time chat online and total messages per row
1 local data is required for UPTIME bot connection time:
When the bot goes online
Architecture
We want to react to several events:
Bot goes online
A message is received
A text status is changed
A voice status is changed
A command stats is received
Bot goes online
Clear tracking data
Add every online users to tracking data
A message is received
Increment the number of message sent for that user today
A voice/test status is changed
Compute uptime for that user
A command stat is received (or bot is closed or arbitrary time passes)
For every users, compute uptime
Produce stats informations
Uptime computation
To compute uptime, we need to know the new user status: For periodic computation, status is unchanged but datetime is updated
Having no row in TRACKING for one user mean he's offline
Given a row in TRACKING corresponding to a given user:
last online time is row time
for each day in the interval between now and the row time:
if the row time is within that day:
uptime for that day is now - last online
otherwise:
uptime for that day is 24h - last online
last online is the next day at 00h
Remove the tracking row if the new status is offline
Roadmap
Server specific
[x] Total users
[x] Average daily users
[x] Total messages
[x] Average daily messages
[x] Average monthly messages
[x] Server 'age' (uptime)
[x] Average daily time spent by users on server (online/active only)
[x] Average monthly time spent by users on server (online/active only)
[x] Total time spent in voice chat (normal + cumulated)
Functional analysis
Total users
Given by the API discord.py
Messages count tracking
We need to be able to track how many messages were sent per day per users.
This will give us the following features:
Users text/voice online tracking
Every time an user goes online: We track which time the user went online Every time an user goes offline: We compute for how long he was online and stores it
This will give us the following features:
Computations Uptimes are computed for every users and the value of online time is set to the last check on some events:
Bot uptime
When starting, bot will remember the time, when asking for uptime, it will simply give the difference with actual time. This will replace "Server 'age' (uptime)"
Corner cases
Queries "per day" should have one row per day even those without data that day
Entities
2 tables are required for TRACKING daily data:
1 table is required for HISTORICAL past days data:
1 local data is required for UPTIME bot connection time: When the bot goes online
Architecture
We want to react to several events:
Bot goes online
A message is received
Increment the number of message sent for that user today
A voice/test status is changed
Compute uptime for that user
A command stat is received (or bot is closed or arbitrary time passes)
Uptime computation
To compute uptime, we need to know the new user status: For periodic computation, status is unchanged but datetime is updated Having no row in TRACKING for one user mean he's offline
Given a row in TRACKING corresponding to a given user:
Remove the tracking row if the new status is offline
Roadmap
Server specific
Leaderboards (top 3/5/10)
User specific
closes #6