@@ -21,6 +21,7 @@ class ReportDataRow(ExportRow):
21
21
allele_counts : int
22
22
gene_symbols_counts : int
23
23
classification_counts : int
24
+ overall_activity : int
24
25
25
26
@export_column (label = "Date" )
26
27
def date_column (self ) -> date :
@@ -46,6 +47,10 @@ def gene_symbols_viewed_column(self) -> int:
46
47
def classifications_viewed_column (self ) -> int :
47
48
return self .classification_counts
48
49
50
+ @export_column (label = "Overall Activity" )
51
+ def overall_activity_column (self ) -> int :
52
+ return self .overall_activity
53
+
49
54
50
55
def week_start_date (freq : datetime .date ) -> datetime .date :
51
56
return freq - timedelta (days = date .weekday (freq ))
@@ -56,23 +61,30 @@ def stream_report_rows(interval) -> Iterator[ReportDataRow]:
56
61
start_of_time_period = datetime .now () - timedelta (days = 365 )
57
62
start_of_time_period = start_of_time_period .date ()
58
63
report_data = defaultdict (lambda : {'users' : set (), 'search_count' : 0 , 'allele_count' : 0 ,
59
- 'gene_symbol_count' : 0 , 'classification_count' : 0 })
64
+ 'gene_symbol_count' : 0 , 'classification_count' : 0 ,
65
+ 'overall_activity' : 0 })
60
66
excluded_users = User .objects .filter (
61
67
Q (is_superuser = True ) | Q (groups__name__in = {'variantgrid/tester' , 'variantgrid/bot' }))
62
68
63
69
metrics_definitions = [
64
70
('variantopedia:search' , 'search_count' , ~ Q (args__search = "" )),
65
71
('variantopedia:view_allele' , 'allele_count' ),
66
72
('genes:view_gene_symbol' , 'gene_symbol_count' , ~ Q (args__gene_symbol = "" )),
67
- ('classification:view_classification' , 'classification_count' )
73
+ ('classification:view_classification' , 'classification_count' ),
74
+ ('' , 'overall_activity' ),
68
75
]
69
76
70
77
ve : ViewEvent
71
78
for view_name , key , * extra_filters in metrics_definitions :
72
- metric_data = ViewEvent .objects .filter (
73
- created__gte = start_of_time_period ,
74
- view_name = view_name
75
- ).exclude (user__in = excluded_users )
79
+ if view_name == '' :
80
+ metric_data = ViewEvent .objects .filter (
81
+ created__gte = start_of_time_period
82
+ ).exclude (user__in = excluded_users )
83
+ else :
84
+ metric_data = ViewEvent .objects .filter (
85
+ created__gte = start_of_time_period ,
86
+ view_name = view_name
87
+ ).exclude (user__in = excluded_users )
76
88
77
89
if extra_filters :
78
90
metric_data = metric_data .filter (* extra_filters )
@@ -92,15 +104,18 @@ def stream_report_rows(interval) -> Iterator[ReportDataRow]:
92
104
93
105
while current_date <= today :
94
106
data = report_data .get (current_date , {'users' : set (), 'search_count' : 0 , 'allele_count' : 0 ,
95
- 'gene_symbol_count' : 0 , 'classification_count' : 0 })
107
+ 'gene_symbol_count' : 0 , 'classification_count' : 0 ,
108
+ 'overall_activity' : 0 })
96
109
user_list = len (data ['users' ])
97
110
searches = data ['search_count' ]
98
111
allele_count = data ['allele_count' ]
99
112
gene_symbol_count = data ['gene_symbol_count' ]
100
113
classification_count = data ['classification_count' ]
114
+ overall_activity = data ['overall_activity' ]
101
115
yield ReportDataRow (date = current_date , user = user_list , search_counts = searches ,
102
116
allele_counts = allele_count , gene_symbols_counts = gene_symbol_count ,
103
- classification_counts = classification_count )
117
+ classification_counts = classification_count ,
118
+ overall_activity = overall_activity )
104
119
current_date += timedelta (days = (1 if interval == 1 else 7 ))
105
120
106
121
0 commit comments