Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding latest month logic #30

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions functions/adoption/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@
DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))
TABLE = 'adoption'

def get_latest_date():
"""Retrieve the latest date in the collection."""
query = DB.collection(TABLE).order_by('date', direction=firestore.Query.DESCENDING).limit(1)
docs = query.stream()
for doc in docs:
return doc.to_dict().get('date')
return None

def list_data(params):

technology_array = convert_to_array(params['technology'])
data = []

if 'end' in params and params['end'] == 'latest':
params['start'] = get_latest_date()

for technology in technology_array:
query = DB.collection(TABLE)

Expand Down
11 changes: 11 additions & 0 deletions functions/cwvtech/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@
DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))
TABLE = 'core_web_vitals'

def get_latest_date():
"""Retrieve the latest date in the collection."""
query = DB.collection(TABLE).order_by('date', direction=firestore.Query.DESCENDING).limit(1)
docs = query.stream()
for doc in docs:
return doc.to_dict().get('date')
return None

def list_data(params):
technology_array = convert_to_array(params['technology'])
data = []

if 'end' in params and params['end'] == 'latest':
params['start'] = get_latest_date()

for technology in technology_array:
query = DB.collection(TABLE)

Expand Down
11 changes: 11 additions & 0 deletions functions/lighthouse/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@
DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))
TABLE = 'lighthouse'

def get_latest_date():
"""Retrieve the latest date in the collection."""
query = DB.collection(TABLE).order_by('date', direction=firestore.Query.DESCENDING).limit(1)
docs = query.stream()
for doc in docs:
return doc.to_dict().get('date')
return None

def list_data(params):

technology_array = convert_to_array(params['technology'])
data = []

if 'end' in params and params['end'] == 'latest':
params['start'] = get_latest_date()

for technology in technology_array:
query = DB.collection(TABLE)

Expand Down
11 changes: 11 additions & 0 deletions functions/page-weight/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@
DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))
TABLE = 'page_weight'

def get_latest_date():
"""Retrieve the latest date in the collection."""
query = DB.collection(TABLE).order_by('date', direction=firestore.Query.DESCENDING).limit(1)
docs = query.stream()
for doc in docs:
return doc.to_dict().get('date')
return None

def list_data(params):

technology_array = convert_to_array(params['technology'])
data = []

if 'end' in params and params['end'] == 'latest':
params['start'] = get_latest_date()

for technology in technology_array:
query = DB.collection(TABLE)

Expand Down
Loading