We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3bcaa3b commit ed32616Copy full SHA for ed32616
functions/page-weight/libs/queries.py
@@ -7,11 +7,22 @@
7
DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))
8
TABLE = 'page_weight'
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
+
18
def list_data(params):
19
20
technology_array = convert_to_array(params['technology'])
21
data = []
22
23
+ if 'end' in params and params['end'] == 'latest':
24
+ params['start'] = get_latest_date()
25
26
for technology in technology_array:
27
query = DB.collection(TABLE)
28
0 commit comments