22from copy import deepcopy
33from time import time
44
5-
65from . import dates as date_util
76
87
@@ -22,7 +21,6 @@ class VizTypes:
2221
2322
2423def update_reports ():
25- global MAX_REPORT_STALENESS
2624 global last_report_update
2725
2826 if (time () - last_report_update ) < MAX_REPORT_STALENESS :
@@ -40,28 +38,24 @@ def update_reports():
4038
4139
4240def get_reports ():
43- global reports_json
4441 update_reports ()
4542
4643 return list (map (get_report , reports_json .get ("_reports" )))
4744
4845
4946def get_featured_reports ():
50- global reports_json
5147 update_reports ()
5248
5349 return map (get_report , reports_json .get ("_featured" ))
5450
5551
5652def map_reports (report_id ): # pragma: no cover
57- global reports_json
5853 report = reports_json .get (report_id )
5954 report ["id" ] = report_id
6055 return report
6156
6257
6358def get_report (report_id ):
64- global reports_json
6559 report = reports_json .get (report_id )
6660 if not report :
6761 return None
@@ -72,7 +66,6 @@ def get_report(report_id):
7266
7367
7468def get_metric (metric_id ):
75- global reports_json
7669 metrics = reports_json .get ("_metrics" )
7770 metric = deepcopy (metrics .get (metric_id ))
7871 if not metric : # pragma: no cover
@@ -82,7 +75,6 @@ def get_metric(metric_id):
8275
8376
8477def get_similar_reports (metric_id , current_report_id ):
85- global reports_json
8678 similar_reports = {}
8779 reports = reports_json .get ("_reports" , [])
8880 for report_id in reports :
@@ -98,16 +90,10 @@ def get_similar_reports(metric_id, current_report_id):
9890
9991
10092def get_dates ():
101- global report_dates
10293 return report_dates
10394
10495
10596def get_latest_date (metric_id ):
106- global report_dates
107- global latest_metric_dates
108- global latest_metric_check
109- global MAX_REPORT_STALENESS
110-
11197 # Check the cache before hitting GCS.
11298 latest_date = latest_metric_dates .get (metric_id )
11399 if latest_date : # pragma: no cover
@@ -128,7 +114,6 @@ def get_latest_date(metric_id):
128114
129115
130116def get_lenses ():
131- global reports_json
132117 # TODO: Consider sorting the lenses by name.
133118 return reports_json .get ("_lens" , {})
134119
0 commit comments