Files
offline-db/users/migrations/0035_seed_marathon_runner_and_millennium_club.py
google-labs-jules[bot] ab0c0b69dd feat(users): added Marathon Runner and Millennium Club badges (#156)
Current Focus Mode: C (The Architect)
Changes Made:
- Added `marathon-runner` (12+ eps in 24h) and `millennium-club` (1000 eps) badges via data migration.
- Implemented awarding logic in `users/badge_system.py`.
- Added unit tests in `users/tests/test_new_badges.py`.

Impact on System:
- Users can now earn two new badges for binge-watching and long-term engagement.
- No performance regression (uses optimized queries).

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-23 18:47:56 +00:00

39 lines
995 B
Python

# Generated by Django 5.1.6 on 2026-01-23 18:41
from django.db import migrations
def seed_badges(apps, schema_editor):
Badge = apps.get_model('users', 'Badge')
# Marathon Runner
Badge.objects.get_or_create(
slug='marathon-runner',
defaults={
'name': 'Marathon Runner',
'description': 'Watched 12+ episodes in the last 24 hours.'
}
)
# Millennium Club
Badge.objects.get_or_create(
slug='millennium-club',
defaults={
'name': 'Millennium Club',
'description': 'Watched 1000 distinct episodes.'
}
)
def remove_badges(apps, schema_editor):
Badge = apps.get_model('users', 'Badge')
Badge.objects.filter(slug__in=['marathon-runner', 'millennium-club']).delete()
class Migration(migrations.Migration):
dependencies = [
("users", "0034_seed_daily_viewer_badge"),
]
operations = [
migrations.RunPython(seed_badges, remove_badges),
]