modified
analytics/settings/__init__.py
@@ -100,6 +100,30 @@ MEDIA_URL = 'media/'MEDIA_ROOT = BASE_DIR / "media"# Database# https://docs.djangoproject.com/en/4.0/ref/settings/#databasesDATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', 'OPTIONS': { 'timeout': 30, 'transaction_mode': 'IMMEDIATE', 'init_command': ( 'PRAGMA journal_mode=WAL;' 'PRAGMA synchronous=NORMAL;' 'PRAGMA foreign_keys=ON;' 'PRAGMA temp_store=MEMORY;' 'PRAGMA mmap_size=134217728;' 'PRAGMA journal_size_limit=67108864;' 'PRAGMA cache_size=-20000;' ), }, }}# Default primary key field type# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
modified
analytics/settings/development.py
@@ -27,17 +27,6 @@ CSRF_TRUSTED_ORIGINS = []# Database# https://docs.djangoproject.com/en/4.0/ref/settings/#databasesDATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', }}# Media files (Images, Videos)# https://docs.djangoproject.com/en/4.0/ref/settings/#media-root
modified
analytics/settings/production.py
@@ -44,12 +44,7 @@ SESSION_COOKIE_SECURE = True# Database# https://docs.djangoproject.com/en/4.0/ref/settings/#databasesDATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": "/data/db/db.sqlite3", }}DATABASES["default"]["NAME"] = "/data/db/db.sqlite3"# Media files (Images, Videos)
added
properties/management/__init__.py
added
properties/management/commands/__init__.py
added
properties/management/commands/prune_events.py
@@ -0,0 +1,24 @@from django.core.management.base import BaseCommandfrom django.utils import timezonefrom properties.models import Eventclass Command(BaseCommand): help = "Delete Event rows older than --days (default 730)." def add_arguments(self, parser): parser.add_argument("--days", type=int, default=730) parser.add_argument("--dry-run", action="store_true") def handle(self, *args, **options): cutoff = timezone.now() - timezone.timedelta(days=options["days"]) qs = Event.objects.filter(created_at__lt=cutoff) count = qs.count() if options["dry_run"]: self.stdout.write(f"Would delete {count} events older than {cutoff.isoformat()}") return deleted, _ = qs.delete() self.stdout.write(f"Deleted {deleted} events older than {cutoff.isoformat()}")