Add indexes to key Hit fields

This commit is contained in:
R. Miles McCain 2021-03-28 19:18:57 +00:00
parent 45fd32c8ca
commit f2e875d03d
2 changed files with 26 additions and 2 deletions

View File

@ -0,0 +1,24 @@
# Generated by Django 3.1.7 on 2021-03-28 19:18
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('analytics', '0004_auto_20210328_1514'),
]
operations = [
migrations.AlterField(
model_name='hit',
name='last_seen',
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
),
migrations.AlterField(
model_name='hit',
name='load_time',
field=models.FloatField(db_index=True, null=True),
),
]

View File

@ -83,7 +83,7 @@ class Hit(models.Model):
# Base request information
start_time = models.DateTimeField(default=timezone.now, db_index=True)
last_seen = models.DateTimeField(default=timezone.now)
last_seen = models.DateTimeField(default=timezone.now, db_index=True)
heartbeats = models.IntegerField(default=0)
tracker = models.TextField(
choices=[("JS", "JavaScript"), ("PIXEL", "Pixel (noscript)")]
@ -92,7 +92,7 @@ class Hit(models.Model):
# Advanced page information
location = models.TextField(blank=True, db_index=True)
referrer = models.TextField(blank=True, db_index=True)
load_time = models.FloatField(null=True)
load_time = models.FloatField(null=True, db_index=True)
class Meta:
ordering = ["-start_time"]