File tree 4 files changed +44
-0
lines changed
4 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 7
7
DB = firestore .Client (project = os .environ .get ('PROJECT' ), database = os .environ .get ('DATABASE' ))
8
8
TABLE = 'adoption'
9
9
10
+ def get_latest_date ():
11
+ """Retrieve the latest date in the collection."""
12
+ query = DB .collection (TABLE ).order_by ('date' , direction = firestore .Query .DESCENDING ).limit (1 )
13
+ docs = query .stream ()
14
+ for doc in docs :
15
+ return doc .to_dict ().get ('date' )
16
+ return None
17
+
10
18
def list_data (params ):
11
19
12
20
technology_array = convert_to_array (params ['technology' ])
13
21
data = []
14
22
23
+ if 'end' in params and params ['end' ] == 'latest' :
24
+ params ['start' ] = get_latest_date ()
25
+
15
26
for technology in technology_array :
16
27
query = DB .collection (TABLE )
17
28
Original file line number Diff line number Diff line change 7
7
DB = firestore .Client (project = os .environ .get ('PROJECT' ), database = os .environ .get ('DATABASE' ))
8
8
TABLE = 'core_web_vitals'
9
9
10
+ def get_latest_date ():
11
+ """Retrieve the latest date in the collection."""
12
+ query = DB .collection (TABLE ).order_by ('date' , direction = firestore .Query .DESCENDING ).limit (1 )
13
+ docs = query .stream ()
14
+ for doc in docs :
15
+ return doc .to_dict ().get ('date' )
16
+ return None
17
+
10
18
def list_data (params ):
11
19
technology_array = convert_to_array (params ['technology' ])
12
20
data = []
13
21
22
+ if 'end' in params and params ['end' ] == 'latest' :
23
+ params ['start' ] = get_latest_date ()
24
+
14
25
for technology in technology_array :
15
26
query = DB .collection (TABLE )
16
27
Original file line number Diff line number Diff line change 7
7
DB = firestore .Client (project = os .environ .get ('PROJECT' ), database = os .environ .get ('DATABASE' ))
8
8
TABLE = 'lighthouse'
9
9
10
+ def get_latest_date ():
11
+ """Retrieve the latest date in the collection."""
12
+ query = DB .collection (TABLE ).order_by ('date' , direction = firestore .Query .DESCENDING ).limit (1 )
13
+ docs = query .stream ()
14
+ for doc in docs :
15
+ return doc .to_dict ().get ('date' )
16
+ return None
17
+
10
18
def list_data (params ):
11
19
12
20
technology_array = convert_to_array (params ['technology' ])
13
21
data = []
14
22
23
+ if 'end' in params and params ['end' ] == 'latest' :
24
+ params ['start' ] = get_latest_date ()
25
+
15
26
for technology in technology_array :
16
27
query = DB .collection (TABLE )
17
28
Original file line number Diff line number Diff line change 7
7
DB = firestore .Client (project = os .environ .get ('PROJECT' ), database = os .environ .get ('DATABASE' ))
8
8
TABLE = 'page_weight'
9
9
10
+ def get_latest_date ():
11
+ """Retrieve the latest date in the collection."""
12
+ query = DB .collection (TABLE ).order_by ('date' , direction = firestore .Query .DESCENDING ).limit (1 )
13
+ docs = query .stream ()
14
+ for doc in docs :
15
+ return doc .to_dict ().get ('date' )
16
+ return None
17
+
10
18
def list_data (params ):
11
19
12
20
technology_array = convert_to_array (params ['technology' ])
13
21
data = []
14
22
23
+ if 'end' in params and params ['end' ] == 'latest' :
24
+ params ['start' ] = get_latest_date ()
25
+
15
26
for technology in technology_array :
16
27
query = DB .collection (TABLE )
17
28
You can’t perform that action at this time.
0 commit comments