Python formatting

This commit is contained in:
Mouse Reeve 2021-10-04 11:16:02 -07:00
parent 551b49b903
commit 2335945a50

View file

@ -46,41 +46,43 @@ class Dashboard(View):
"active": lambda q, s, e: q.filter( "active": lambda q, s, e: q.filter(
Q(is_active=True) | Q(deactivation_date__gt=e), Q(is_active=True) | Q(deactivation_date__gt=e),
created_date__lte=e, created_date__lte=e,
).filter( )
.filter(
last_active_date__gt=e - timedelta(days=31), last_active_date__gt=e - timedelta(days=31),
).count() )
} .count(),
},
) )
status_queryset = models.Status.objects.filter(user__local=True, deleted=False) status_queryset = models.Status.objects.filter(user__local=True, deleted=False)
status_chart = Chart( status_chart = Chart(
queryset=status_queryset, queryset=status_queryset,
queries = { queries={
"total": lambda q, s, e: q.filter( "total": lambda q, s, e: q.filter(
created_date__gt=s, created_date__gt=s,
created_date__lte=e, created_date__lte=e,
).count() ).count()
} },
) )
register_chart = Chart( register_chart = Chart(
queryset=user_queryset, queryset=user_queryset,
queries = { queries={
"total": lambda q, s, e: q.filter( "total": lambda q, s, e: q.filter(
created_date__gt=s, created_date__gt=s,
created_date__lte=e, created_date__lte=e,
).count() ).count()
} },
) )
works_chart = Chart( works_chart = Chart(
queryset=models.Work.objects, queryset=models.Work.objects,
queries = { queries={
"total": lambda q, s, e: q.filter( "total": lambda q, s, e: q.filter(
created_date__gt=s, created_date__gt=s,
created_date__lte=e, created_date__lte=e,
).count() ).count()
} },
) )
data = { data = {
@ -106,14 +108,14 @@ class Dashboard(View):
class Chart: class Chart:
""" Data for a chart """ """Data for a chart"""
def __init__(self, queryset, queries: dict): def __init__(self, queryset, queries: dict):
self.queryset = queryset self.queryset = queryset
self.queries = queries self.queries = queries
def get_chart(self, start, end, interval): def get_chart(self, start, end, interval):
""" load the data for the chart given a time scale and interval """ """load the data for the chart given a time scale and interval"""
interval_start = start interval_start = start
interval_end = interval_start + timedelta(days=interval) interval_end = interval_start + timedelta(days=interval)