Skip to content

Commit afb4369

Browse files
committed
fixed asc desc query
1 parent 2818287 commit afb4369

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

functions/technologies/libs/queries.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def list_data(params):
1414
onlyname = False
15-
ref = DB.collection(u'technologies')
15+
ref = DB.collection('technologies')
1616

1717
query = ref
1818

@@ -26,14 +26,20 @@ def list_data(params):
2626

2727
query = query.where(filter=or_filter)
2828

29-
3029
if 'category' in params:
3130
params_array = convert_to_array(params['category'])
3231
query = query.where(filter=FieldFilter('category_obj', 'array_contains_any', params_array))
3332

3433
if 'onlyname' in params:
3534
onlyname = True
3635

36+
if 'sort' not in params:
37+
query = query.order_by('technology', direction=firestore.Query.ASCENDING)
38+
else:
39+
if params['sort'] == 'origins':
40+
query = query.order_by('origins', direction=firestore.Query.DESCENDING)
41+
42+
3743
documents = query.stream()
3844

3945
data = []

0 commit comments

Comments
 (0)