Skip to content

Commit

Permalink
categories filter no mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
maceto committed Feb 10, 2024
1 parent 39b9f19 commit 8ea3b44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion functions/categories/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ def list_data(params):
category_array = convert_to_array(params['category'])

for category in category_array:
results = DB.collection(u'categories').where("category", "==", category).stream()
results = query.where("category", "==", category).stream()
for doc in results:
data.append(doc.to_dict())

else:
documents = query.stream()

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

return Result(result=data)
6 changes: 3 additions & 3 deletions functions/categories/libs/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def __init__(self, params):
def validate(self):
result = Result(status="ok", result="()")

if 'onlyname' not in self.params:
if 'category' not in self.params:
self.add_error("category", "missing category parameter")
# if 'onlyname' not in self.params:
# if 'category' not in self.params:
# self.add_error("category", "missing category parameter")

return Result(errors=self.errors, result=self.params)

Expand Down

0 comments on commit 8ea3b44

Please sign in to comment.