Skip to content

Commit

Permalink
executing one query many where
Browse files Browse the repository at this point in the history
  • Loading branch information
maceto committed Jul 23, 2024
1 parent 7f12b2c commit 6965132
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions functions/lighthouse/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ def list_data(params):
technology_array = convert_to_array(params['technology'])
data = []

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

if 'start' in params:
query = query.where(filter=FieldFilter('date', '>=', params['start']))
if 'end' in params:
query = query.where(filter=FieldFilter('date', '<=', params['end']))
if 'start' in params:
query = query.where(filter=FieldFilter('date', '>=', params['start']))
if 'end' in params:
query = query.where(filter=FieldFilter('date', '<=', params['end']))

query = query.where(filter=FieldFilter('geo', '==', params['geo']))
query = query.where(filter=FieldFilter('rank', '==', params['rank']))
query = query.where(filter=FieldFilter('geo', '==', params['geo']))
query = query.where(filter=FieldFilter('rank', '==', params['rank']))

for technology in technology_array:
query = query.where(filter=FieldFilter('technology', '==', technology))

documents = query.stream()
documents = query.stream()

for doc in documents:
data.append(doc.to_dict())
for doc in documents:
data.append(doc.to_dict())

return Result(result=data)

0 comments on commit 6965132

Please sign in to comment.