From 8bab14cc8abba63f3559718ce8847c7bef423c8a Mon Sep 17 00:00:00 2001 From: "R. Miles McCain" Date: Mon, 29 Mar 2021 15:04:36 +0000 Subject: [PATCH] Separate bounce migration into two --- .../migrations/0008_session_is_bounce.py | 12 +---------- .../migrations/0009_auto_20210329_1100.py | 21 +++++++++++++++++++ shynet/shynet/settings.py | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 shynet/analytics/migrations/0009_auto_20210329_1100.py diff --git a/shynet/analytics/migrations/0008_session_is_bounce.py b/shynet/analytics/migrations/0008_session_is_bounce.py index 0e69eea..c5dfff0 100644 --- a/shynet/analytics/migrations/0008_session_is_bounce.py +++ b/shynet/analytics/migrations/0008_session_is_bounce.py @@ -1,15 +1,6 @@ # 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.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): @@ -23,6 +14,5 @@ class Migration(migrations.Migration): model_name="session", name="is_bounce", field=models.BooleanField(db_index=True, default=True), - ), - migrations.RunPython(update_bounce_stats, lambda: ()), + ) ] diff --git a/shynet/analytics/migrations/0009_auto_20210329_1100.py b/shynet/analytics/migrations/0009_auto_20210329_1100.py new file mode 100644 index 0000000..fb7ae13 --- /dev/null +++ b/shynet/analytics/migrations/0009_auto_20210329_1100.py @@ -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: ()), + ] diff --git a/shynet/shynet/settings.py b/shynet/shynet/settings.py index c7086bc..4f9be36 100644 --- a/shynet/shynet/settings.py +++ b/shynet/shynet/settings.py @@ -18,7 +18,7 @@ import urllib.parse as urlparse from django.contrib.messages import constants as messages # Increment on new releases -VERSION = "v0.8.1" +VERSION = "v0.8.2alpha" # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))