django-db-time-decay-scoring
Installation
SKILL.md
Django DB-Level Time Decay Feed Scoring
When to Use
- Replacing chronological feed (
order_by("-created_at")) with engagement + freshness scoring - Implementing Hacker News-style ranking where new content competes with older popular content
- Need for DB-level sorting (no Python-side sorting of full querysets)
- Must work on both SQLite (dev) and PostgreSQL (prod)
The Formula
score = (like_count + comment_count * COMMENT_WEIGHT + featured_boost) / (age_hours + 2)
age_hours: hours sincecreated_at(NOTupdated_at— usecreated_atso edits don't inflate score)+ 2in denominator: prevents division by near-zero for very new content, stabilises first 2 hourscomment_count * 2: comments signal deeper engagement than likesfeatured_boost: flat additive boost for curated/featured content