Add trending endpoint
Changes:
- Maintains 2 new keys in redis
trending_chars
andtrending_fresh
-
trending_chars
- Stores a list of characters in order by how many unique players played them in the past 3 days -
trending_fresh
- A flag which expires every night at 00:00. Expiration indicates the trending list is stale and needs to be regenerated.
-
- Adds trending endpoint
GET /trending/characters
- Reads
trending_chars
from redis and returns the characters as a dictionary of character name => trending rank - If
trending_chars
does not exist the server notify the client the data is not yet ready and start a background task to generate the list - Starts a background task to check the freshness of the data. If
trending_fresh
has expired, regenerates the trending list with fresh data
- Reads
Clients will recieve a list of characters with their trending "rank" starting with 1 as the highest. Clients will not be able to see exact play counts, unique ips, etc.
Tested locally with mongo and redis. Mongo pipeline reused from the discord bot so it should work. Only ever pulling 3 days worth of data at most once per day.
Edited by Lokkit