Skip to content

Commit fe8e766

Browse files
committed
Format
1 parent b63863e commit fe8e766

20 files changed

+115
-72
lines changed

shynet/a17t/templatetags/pagination.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ def pagination(
1616
after_current_pages=4,
1717
):
1818
url_parameters = urlencode(
19-
[
20-
(key, value)
21-
for key, value in request.GET.items()
22-
if key != "page"
23-
]
19+
[(key, value) for key, value in request.GET.items() if key != "page"]
2420
)
2521

2622
before = max(page.number - before_current_pages - 1, 0)

shynet/analytics/migrations/0001_initial.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ class Migration(migrations.Migration):
6060
),
6161
),
6262
],
63-
options={"ordering": ["-start_time"],},
63+
options={
64+
"ordering": ["-start_time"],
65+
},
6466
),
6567
migrations.CreateModel(
6668
name="Hit",
@@ -90,7 +92,9 @@ class Migration(migrations.Migration):
9092
),
9193
),
9294
],
93-
options={"ordering": ["-start_time"],},
95+
options={
96+
"ordering": ["-start_time"],
97+
},
9498
),
9599
migrations.AddIndex(
96100
model_name="session",

shynet/analytics/migrations/0004_auto_20210328_1514.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,40 @@
77
class Migration(migrations.Migration):
88

99
dependencies = [
10-
('analytics', '0003_auto_20200502_1227'),
10+
("analytics", "0003_auto_20200502_1227"),
1111
]
1212

1313
operations = [
1414
migrations.AlterField(
15-
model_name='hit',
16-
name='last_seen',
15+
model_name="hit",
16+
name="last_seen",
1717
field=models.DateTimeField(default=django.utils.timezone.now),
1818
),
1919
migrations.AlterField(
20-
model_name='hit',
21-
name='start_time',
22-
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
20+
model_name="hit",
21+
name="start_time",
22+
field=models.DateTimeField(
23+
db_index=True, default=django.utils.timezone.now
24+
),
2325
),
2426
migrations.AlterField(
25-
model_name='session',
26-
name='last_seen',
27-
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
27+
model_name="session",
28+
name="last_seen",
29+
field=models.DateTimeField(
30+
db_index=True, default=django.utils.timezone.now
31+
),
2832
),
2933
migrations.AlterField(
30-
model_name='session',
31-
name='start_time',
32-
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
34+
model_name="session",
35+
name="start_time",
36+
field=models.DateTimeField(
37+
db_index=True, default=django.utils.timezone.now
38+
),
3339
),
3440
migrations.AddIndex(
35-
model_name='session',
36-
index=models.Index(fields=['service', '-last_seen'], name='analytics_s_service_10bb96_idx'),
41+
model_name="session",
42+
index=models.Index(
43+
fields=["service", "-last_seen"], name="analytics_s_service_10bb96_idx"
44+
),
3745
),
3846
]

shynet/analytics/migrations/0005_auto_20210328_1518.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
class Migration(migrations.Migration):
88

99
dependencies = [
10-
('analytics', '0004_auto_20210328_1514'),
10+
("analytics", "0004_auto_20210328_1514"),
1111
]
1212

1313
operations = [
1414
migrations.AlterField(
15-
model_name='hit',
16-
name='last_seen',
17-
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
15+
model_name="hit",
16+
name="last_seen",
17+
field=models.DateTimeField(
18+
db_index=True, default=django.utils.timezone.now
19+
),
1820
),
1921
migrations.AlterField(
20-
model_name='hit',
21-
name='load_time',
22+
model_name="hit",
23+
name="load_time",
2224
field=models.FloatField(db_index=True, null=True),
2325
),
2426
]

shynet/analytics/migrations/0006_hit_service.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,36 @@
55
import django.db.models.deletion
66
from django.db.models import Subquery, OuterRef
77

8+
89
def add_service_to_hits(_a, _b):
9-
service = Session.objects.filter(
10-
pk=OuterRef('session')
11-
).values_list(
12-
'service'
13-
)[:1]
10+
service = Session.objects.filter(pk=OuterRef("session")).values_list("service")[:1]
11+
12+
Hit.objects.update(service=Subquery(service))
1413

15-
Hit.objects.update(
16-
service=Subquery(service)
17-
)
1814

1915
class Migration(migrations.Migration):
2016

2117
dependencies = [
22-
('core', '0008_auto_20200628_1403'),
23-
('analytics', '0005_auto_20210328_1518'),
18+
("core", "0008_auto_20200628_1403"),
19+
("analytics", "0005_auto_20210328_1518"),
2420
]
2521

2622
operations = [
2723
migrations.AddField(
28-
model_name='hit',
29-
name='service',
30-
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.service'),
24+
model_name="hit",
25+
name="service",
26+
field=models.ForeignKey(
27+
null=True,
28+
on_delete=django.db.models.deletion.CASCADE,
29+
to="core.service",
30+
),
3131
),
3232
migrations.RunPython(add_service_to_hits, lambda: ()),
3333
migrations.AlterField(
34-
model_name='hit',
35-
name='service',
36-
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.service'),
34+
model_name="hit",
35+
name="service",
36+
field=models.ForeignKey(
37+
on_delete=django.db.models.deletion.CASCADE, to="core.service"
38+
),
3739
),
3840
]

shynet/analytics/migrations/0007_auto_20210328_1634.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
class Migration(migrations.Migration):
77

88
dependencies = [
9-
('analytics', '0006_hit_service'),
9+
("analytics", "0006_hit_service"),
1010
]
1111

1212
operations = [
1313
migrations.AddIndex(
14-
model_name='hit',
15-
index=models.Index(fields=['service', '-start_time'], name='analytics_h_service_f4f41e_idx'),
14+
model_name="hit",
15+
index=models.Index(
16+
fields=["service", "-start_time"], name="analytics_h_service_f4f41e_idx"
17+
),
1618
),
1719
]

shynet/analytics/migrations/0008_session_is_bounce.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55
from django.db import migrations, models
66
from django.db.models import Subquery, OuterRef
77

8+
89
def update_bounce_stats(_a, _b):
9-
Session.objects.all().annotate(hit_count=models.Count("hit")).filter(hit_count__gt=1).update(is_bounce=False)
10+
Session.objects.all().annotate(hit_count=models.Count("hit")).filter(
11+
hit_count__gt=1
12+
).update(is_bounce=False)
13+
1014

1115
class Migration(migrations.Migration):
1216

1317
dependencies = [
14-
('analytics', '0007_auto_20210328_1634'),
18+
("analytics", "0007_auto_20210328_1634"),
1519
]
1620

1721
operations = [
1822
migrations.AddField(
19-
model_name='session',
20-
name='is_bounce',
23+
model_name="session",
24+
name="is_bounce",
2125
field=models.BooleanField(db_index=True, default=True),
2226
),
2327
migrations.RunPython(update_bounce_stats, lambda: ()),

shynet/analytics/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def ingress_request(
184184
load_time=payload.get("loadTime"),
185185
start_time=time,
186186
last_seen=time,
187-
service=service
187+
service=service,
188188
)
189189

190190
# Recalculate whether the session is a bounce

shynet/analytics/views/ingress.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ def get(self, *args, **kwargs):
112112
endpoint = (
113113
reverse(
114114
"ingress:endpoint_script",
115-
kwargs={"service_uuid": self.kwargs.get("service_uuid"),},
115+
kwargs={
116+
"service_uuid": self.kwargs.get("service_uuid"),
117+
},
116118
)
117119
if self.kwargs.get("identifier") == None
118120
else reverse(

shynet/core/management/commands/demo.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ class Command(BaseCommand):
5454

5555
def add_arguments(self, parser):
5656
parser.add_argument(
57-
"name", type=str,
57+
"name",
58+
type=str,
5859
)
5960
parser.add_argument("owner_email", type=str)
6061
parser.add_argument(
61-
"avg", type=int,
62+
"avg",
63+
type=int,
6264
)
6365
parser.add_argument("deviation", type=float, default=0.4)
6466
parser.add_argument(
65-
"days", type=int,
67+
"days",
68+
type=int,
6669
)
6770
parser.add_argument("load_time", type=float, default=1000)
6871

0 commit comments

Comments
 (0)