mirror of
https://github.com/barkeser2002/offline-db.git
synced 2026-09-25 02:19:59 +03:00
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>
39 lines
995 B
Python
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),
|
|
]
|