File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
functions/categories/libs Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 2
2
import json
3
3
from google .cloud import firestore
4
4
from .result import Result
5
+ from .utils import convert_to_array
5
6
6
7
DB = firestore .Client (project = os .environ .get ('PROJECT' ))
7
8
@@ -10,13 +11,13 @@ def list_data(params):
10
11
11
12
query = ref
12
13
14
+ if 'technology' in params :
15
+ params_array = convert_to_array (params ['technology' ])
16
+ query = query .where ('technology' , 'in' , params_array )
17
+
13
18
if 'category' in params :
14
- category_array = json .loads (params ['category' ])
15
- query = query .where ('category' , 'in' , category_array )
16
-
17
- if 'technologies' in params :
18
- params_array = json .loads (params ['technologies' ])
19
- query = query .where ('technologies' , 'in' , params_array )
19
+ params_array = convert_to_array (params ['category' ])
20
+ query = query .where ('category' , 'in' , params_array )
20
21
21
22
documents = query .stream ()
22
23
Original file line number Diff line number Diff line change @@ -11,3 +11,7 @@ def convert_to_hashes(arr):
11
11
hash_dict = {inner_arr [0 ]: inner_arr [1 ]}
12
12
hashes_arr .append (hash_dict )
13
13
return hashes_arr
14
+
15
+ def convert_to_array (data_string ):
16
+ list = data_string .split (',' )
17
+ return list
You can’t perform that action at this time.
0 commit comments