Separate bounce migration into two

This commit is contained in:
R. Miles McCain 2021-03-29 15:04:36 +00:00
parent fe8e766670
commit 8bab14cc8a
3 changed files with 23 additions and 12 deletions

View File

@ -1,15 +1,6 @@
# Generated by Django 3.1.7 on 2021-03-28 21:38 # Generated by Django 3.1.7 on 2021-03-28 21:38
from django.db.models.expressions import F
from ..models import Session, Hit
from django.db import migrations, models from django.db import migrations, models
from django.db.models import Subquery, OuterRef
def update_bounce_stats(_a, _b):
Session.objects.all().annotate(hit_count=models.Count("hit")).filter(
hit_count__gt=1
).update(is_bounce=False)
class Migration(migrations.Migration): class Migration(migrations.Migration):
@ -23,6 +14,5 @@ class Migration(migrations.Migration):
model_name="session", model_name="session",
name="is_bounce", name="is_bounce",
field=models.BooleanField(db_index=True, default=True), field=models.BooleanField(db_index=True, default=True),
), )
migrations.RunPython(update_bounce_stats, lambda: ()),
] ]

View File

@ -0,0 +1,21 @@
# Generated by Django 3.1.7 on 2021-03-29 15:00
from django.db import migrations, models
from ..models import Session
def update_bounce_stats(_a, _b):
Session.objects.all().annotate(hit_count=models.Count("hit")).filter(
hit_count__gt=1
).update(is_bounce=False)
class Migration(migrations.Migration):
dependencies = [
("analytics", "0008_session_is_bounce"),
]
operations = [
migrations.RunPython(update_bounce_stats, lambda: ()),
]

View File

@ -18,7 +18,7 @@ import urllib.parse as urlparse
from django.contrib.messages import constants as messages from django.contrib.messages import constants as messages
# Increment on new releases # Increment on new releases
VERSION = "v0.8.1" VERSION = "v0.8.2alpha"
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))