Format
This commit is contained in:
parent
b63863e283
commit
fe8e766670
@ -16,11 +16,7 @@ def pagination(
|
||||
after_current_pages=4,
|
||||
):
|
||||
url_parameters = urlencode(
|
||||
[
|
||||
(key, value)
|
||||
for key, value in request.GET.items()
|
||||
if key != "page"
|
||||
]
|
||||
[(key, value) for key, value in request.GET.items() if key != "page"]
|
||||
)
|
||||
|
||||
before = max(page.number - before_current_pages - 1, 0)
|
||||
|
@ -60,7 +60,9 @@ class Migration(migrations.Migration):
|
||||
),
|
||||
),
|
||||
],
|
||||
options={"ordering": ["-start_time"],},
|
||||
options={
|
||||
"ordering": ["-start_time"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Hit",
|
||||
@ -90,7 +92,9 @@ class Migration(migrations.Migration):
|
||||
),
|
||||
),
|
||||
],
|
||||
options={"ordering": ["-start_time"],},
|
||||
options={
|
||||
"ordering": ["-start_time"],
|
||||
},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="session",
|
||||
|
@ -7,32 +7,40 @@ import django.utils.timezone
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0003_auto_20200502_1227'),
|
||||
("analytics", "0003_auto_20200502_1227"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='hit',
|
||||
name='last_seen',
|
||||
model_name="hit",
|
||||
name="last_seen",
|
||||
field=models.DateTimeField(default=django.utils.timezone.now),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hit',
|
||||
name='start_time',
|
||||
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
|
||||
model_name="hit",
|
||||
name="start_time",
|
||||
field=models.DateTimeField(
|
||||
db_index=True, default=django.utils.timezone.now
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='session',
|
||||
name='last_seen',
|
||||
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
|
||||
model_name="session",
|
||||
name="last_seen",
|
||||
field=models.DateTimeField(
|
||||
db_index=True, default=django.utils.timezone.now
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='session',
|
||||
name='start_time',
|
||||
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
|
||||
model_name="session",
|
||||
name="start_time",
|
||||
field=models.DateTimeField(
|
||||
db_index=True, default=django.utils.timezone.now
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='session',
|
||||
index=models.Index(fields=['service', '-last_seen'], name='analytics_s_service_10bb96_idx'),
|
||||
model_name="session",
|
||||
index=models.Index(
|
||||
fields=["service", "-last_seen"], name="analytics_s_service_10bb96_idx"
|
||||
),
|
||||
),
|
||||
]
|
||||
|
@ -7,18 +7,20 @@ import django.utils.timezone
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0004_auto_20210328_1514'),
|
||||
("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),
|
||||
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',
|
||||
model_name="hit",
|
||||
name="load_time",
|
||||
field=models.FloatField(db_index=True, null=True),
|
||||
),
|
||||
]
|
||||
|
@ -5,34 +5,36 @@ from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.db.models import Subquery, OuterRef
|
||||
|
||||
def add_service_to_hits(_a, _b):
|
||||
service = Session.objects.filter(
|
||||
pk=OuterRef('session')
|
||||
).values_list(
|
||||
'service'
|
||||
)[:1]
|
||||
|
||||
Hit.objects.update(
|
||||
service=Subquery(service)
|
||||
)
|
||||
def add_service_to_hits(_a, _b):
|
||||
service = Session.objects.filter(pk=OuterRef("session")).values_list("service")[:1]
|
||||
|
||||
Hit.objects.update(service=Subquery(service))
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0008_auto_20200628_1403'),
|
||||
('analytics', '0005_auto_20210328_1518'),
|
||||
("core", "0008_auto_20200628_1403"),
|
||||
("analytics", "0005_auto_20210328_1518"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='hit',
|
||||
name='service',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.service'),
|
||||
model_name="hit",
|
||||
name="service",
|
||||
field=models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="core.service",
|
||||
),
|
||||
),
|
||||
migrations.RunPython(add_service_to_hits, lambda: ()),
|
||||
migrations.AlterField(
|
||||
model_name='hit',
|
||||
name='service',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.service'),
|
||||
model_name="hit",
|
||||
name="service",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to="core.service"
|
||||
),
|
||||
),
|
||||
]
|
||||
|
@ -6,12 +6,14 @@ from django.db import migrations, models
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0006_hit_service'),
|
||||
("analytics", "0006_hit_service"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name='hit',
|
||||
index=models.Index(fields=['service', '-start_time'], name='analytics_h_service_f4f41e_idx'),
|
||||
model_name="hit",
|
||||
index=models.Index(
|
||||
fields=["service", "-start_time"], name="analytics_h_service_f4f41e_idx"
|
||||
),
|
||||
),
|
||||
]
|
||||
|
@ -5,19 +5,23 @@ 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)
|
||||
Session.objects.all().annotate(hit_count=models.Count("hit")).filter(
|
||||
hit_count__gt=1
|
||||
).update(is_bounce=False)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0007_auto_20210328_1634'),
|
||||
("analytics", "0007_auto_20210328_1634"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='session',
|
||||
name='is_bounce',
|
||||
model_name="session",
|
||||
name="is_bounce",
|
||||
field=models.BooleanField(db_index=True, default=True),
|
||||
),
|
||||
migrations.RunPython(update_bounce_stats, lambda: ()),
|
||||
|
@ -184,7 +184,7 @@ def ingress_request(
|
||||
load_time=payload.get("loadTime"),
|
||||
start_time=time,
|
||||
last_seen=time,
|
||||
service=service
|
||||
service=service,
|
||||
)
|
||||
|
||||
# Recalculate whether the session is a bounce
|
||||
|
@ -112,7 +112,9 @@ class ScriptView(ValidateServiceOriginsMixin, View):
|
||||
endpoint = (
|
||||
reverse(
|
||||
"ingress:endpoint_script",
|
||||
kwargs={"service_uuid": self.kwargs.get("service_uuid"),},
|
||||
kwargs={
|
||||
"service_uuid": self.kwargs.get("service_uuid"),
|
||||
},
|
||||
)
|
||||
if self.kwargs.get("identifier") == None
|
||||
else reverse(
|
||||
|
@ -54,15 +54,18 @@ class Command(BaseCommand):
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"name", type=str,
|
||||
"name",
|
||||
type=str,
|
||||
)
|
||||
parser.add_argument("owner_email", type=str)
|
||||
parser.add_argument(
|
||||
"avg", type=int,
|
||||
"avg",
|
||||
type=int,
|
||||
)
|
||||
parser.add_argument("deviation", type=float, default=0.4)
|
||||
parser.add_argument(
|
||||
"days", type=int,
|
||||
"days",
|
||||
type=int,
|
||||
)
|
||||
parser.add_argument("load_time", type=float, default=1000)
|
||||
|
||||
|
@ -14,7 +14,8 @@ class Command(BaseCommand):
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"hostname", type=str,
|
||||
"hostname",
|
||||
type=str,
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
@ -14,7 +14,8 @@ class Command(BaseCommand):
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"email", type=str,
|
||||
"email",
|
||||
type=str,
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
@ -14,7 +14,8 @@ class Command(BaseCommand):
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"name", type=str,
|
||||
"name",
|
||||
type=str,
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
@ -112,7 +112,9 @@ class Migration(migrations.Migration):
|
||||
"verbose_name_plural": "users",
|
||||
"abstract": False,
|
||||
},
|
||||
managers=[("objects", django.contrib.auth.models.UserManager()),],
|
||||
managers=[
|
||||
("objects", django.contrib.auth.models.UserManager()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Service",
|
||||
|
@ -11,6 +11,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="service", options={"ordering": ["name", "uuid"]},
|
||||
name="service",
|
||||
options={"ordering": ["name", "uuid"]},
|
||||
),
|
||||
]
|
||||
|
@ -244,4 +244,7 @@ class Service(models.Model):
|
||||
}
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("dashboard:service", kwargs={"pk": self.pk},)
|
||||
return reverse(
|
||||
"dashboard:service",
|
||||
kwargs={"pk": self.pk},
|
||||
)
|
||||
|
@ -44,7 +44,12 @@ def country_name(isocode):
|
||||
|
||||
@register.simple_tag
|
||||
def relative_stat_tone(
|
||||
start, end, good="UP", good_classes=None, bad_classes=None, neutral_classes=None,
|
||||
start,
|
||||
end,
|
||||
good="UP",
|
||||
good_classes=None,
|
||||
bad_classes=None,
|
||||
neutral_classes=None,
|
||||
):
|
||||
good_classes = good_classes or "~positive"
|
||||
bad_classes = bad_classes or "~critical"
|
||||
|
@ -22,9 +22,7 @@ from .forms import ServiceForm
|
||||
from .mixins import DateRangeMixin
|
||||
|
||||
|
||||
class DashboardView(
|
||||
LoginRequiredMixin, DateRangeMixin, ListView
|
||||
):
|
||||
class DashboardView(LoginRequiredMixin, DateRangeMixin, ListView):
|
||||
model = Service
|
||||
template_name = "dashboard/pages/dashboard.html"
|
||||
paginate_by = 5
|
||||
@ -38,7 +36,9 @@ class DashboardView(
|
||||
data = super().get_context_data(**kwargs)
|
||||
|
||||
for service in data["object_list"]:
|
||||
service.stats = service.get_core_stats(self.get_start_date(), self.get_end_date())
|
||||
service.stats = service.get_core_stats(
|
||||
self.get_start_date(), self.get_end_date()
|
||||
)
|
||||
|
||||
return data
|
||||
|
||||
|
@ -58,7 +58,7 @@ INSTALLED_APPS = [
|
||||
"allauth",
|
||||
"allauth.account",
|
||||
"allauth.socialaccount",
|
||||
"debug_toolbar"
|
||||
"debug_toolbar",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@ -147,9 +147,15 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
||||
},
|
||||
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
|
||||
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
|
||||
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
||||
},
|
||||
]
|
||||
|
||||
# Logging
|
||||
@ -250,7 +256,7 @@ LOGIN_REDIRECT_URL = "/"
|
||||
SITE_ID = 1
|
||||
|
||||
INTERNAL_IPS = [
|
||||
'127.0.0.1',
|
||||
"127.0.0.1",
|
||||
]
|
||||
|
||||
# Celery
|
||||
|
@ -18,7 +18,7 @@ from django.urls import include, path
|
||||
import debug_toolbar
|
||||
|
||||
urlpatterns = [
|
||||
path('__debug__/', include(debug_toolbar.urls)),
|
||||
path("__debug__/", include(debug_toolbar.urls)),
|
||||
path("admin/", admin.site.urls),
|
||||
path("accounts/", include("allauth.urls")),
|
||||
path("ingress/", include(("analytics.ingress_urls", "ingress")), name="ingress"),
|
||||
|
Loading…
Reference in New Issue
Block a user