Study Together! Codebase
(optional) Create a virtual environment
pip3 install -r requirements.txt
Set up MySQL database and Redis
(optional) Get credentials from the dev team (optional) If you are using PyCharm, install .env files support for env file autocompletion.
insert_data.py
timezone_bot.py
time_counter.py
All rights reserved until I figure out which license is compatible with the used libraries.
Discord chatroom
- 45k members in total (30 days 5k, over 10%)
- Concurrently could reach ~5k+ members in diff channels
- Rate of requests about 5/sec
-
The rankings are based on the following
- all-time
- monthly (reset at UTC 5pm)
- weekly (reset at UTC 5pm)
- daily (reset at UTC 5pm)
- minutes (every single minute in the past 24h)
-
Auto restart when the discord bot dies
-
Show streak
A process listens to events from discord api when members join/leave study channels or request stats. This process will insert logs into a SQL database (not any analytical data).
Another bot will use in memory sorted sets (also called skip lists) in-memory cache Redis to maintain the users' scores and rankings. Each ranking has a different sorted sets. num of sorted set: 1 + 1 + 1 + 24 * 60
past 24h ranking not fully accurate event based
streaks used:
daily Ranking last 24 hours (bad idea; your study time from yesterday influences your studytime and ranking today) periodic calculating the ranking not accurate, not real time, the wait time will keep increasing