Popularity computation background job #114
Notifications
Due Date
No due date set.
Blocks
Depends on
#110 Views tracking, featured albums & cosplayers, and popularity-based trending
MilkyShots/MilkyShots
#115 Popular/trending API endpoints
MilkyShots/MilkyShots
#113 View recording API endpoints with rate limiting
MilkyShots/MilkyShots
Reference: MilkyShots/MilkyShots#114
Reference in New Issue
Block a user
Add a scheduled background job that aggregates view log data into popularity scores for each timeframe (Daily, Weekly, Monthly, AllTime).
Job:
ComputePopularityJobExtends the existing
Jobabstract class (likeFileSystemCrawlJob,ThumbnailJob, etc.).Algorithm
For each entity type (Asset, Album, Person) and each timeframe:
For each (entity, timeframe) pair:
(ViewerIp, ViewerUserId)tuples per entity within the windowCaching
Write results to an in-memory cache (
IMemoryCacheorConcurrentDictionary) for fast API reads. Optionally back it with aPopularityCacheDB table for persistence across restarts.Scheduling
JobSchedulerto run nightly (e.g.,Timer(TimeSpan.FromHours(24)))/api/jobs(admin) via existing job infrastructureEdge cases
Settings integration
Read thresholds from settings (see #117):
PopularMinViews— minimum views to qualifyPopularMaxResults— top-N limit per timeframePart of: #110