Skip to content

Commit

Permalink
multi techonologies issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maceto committed Nov 28, 2023
1 parent a91d4be commit be3d94f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 7 deletions.
4 changes: 3 additions & 1 deletion functions/adoption/libs/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from urllib.parse import unquote

def output(result, headers={}):
status = 200 if result.success() else 400
Expand All @@ -13,5 +14,6 @@ def convert_to_hashes(arr):
return hashes_arr

def convert_to_array(data_string):
list = data_string.split(',')
decoded_data = unquote(data_string)
list = decoded_data.split(',')
return list
4 changes: 3 additions & 1 deletion functions/categories/libs/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from urllib.parse import unquote

def output(result, headers={}):
status = 200 if result.success() else 400
Expand All @@ -13,5 +14,6 @@ def convert_to_hashes(arr):
return hashes_arr

def convert_to_array(data_string):
list = data_string.split(',')
decoded_data = unquote(data_string)
list = decoded_data.split(',')
return list
8 changes: 6 additions & 2 deletions functions/cwvtech/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
from google.cloud import firestore
from .result import Result
from .utils import convert_to_array

DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))

Expand All @@ -14,11 +15,14 @@ def list_data(params):
query = query.where('date', '>=', params['start'])
if 'end' in params:
query = query.where('date', '<=', params['end'])

if 'geo' in params:
query = query.where('geo', '==', params['geo'])

if 'technology' in params:
query = query.where('technology', '==', params['technology'])
params_array = convert_to_array(params['technology'])
query = query.where('technology', 'in', params_array)

if 'rank' in params:
query = query.where('rank', '==', params['rank'])

Expand Down
6 changes: 6 additions & 0 deletions functions/cwvtech/libs/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from urllib.parse import unquote

def output(result, headers={}):
status = 200 if result.success() else 400
Expand All @@ -11,3 +12,8 @@ def convert_to_hashes(arr):
hash_dict = {inner_arr[0]: inner_arr[1]}
hashes_arr.append(hash_dict)
return hashes_arr

def convert_to_array(data_string):
decoded_data = unquote(data_string)
list = decoded_data.split(',')
return list
4 changes: 3 additions & 1 deletion functions/lighthouse/libs/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from urllib.parse import unquote

def output(result, headers={}):
status = 200 if result.success() else 400
Expand All @@ -13,5 +14,6 @@ def convert_to_hashes(arr):
return hashes_arr

def convert_to_array(data_string):
list = data_string.split(',')
decoded_data = unquote(data_string)
list = decoded_data.split(',')
return list
2 changes: 2 additions & 0 deletions functions/page-weight/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def list_data(params):
query = query.where('date', '<=', params['end'])
if 'geo' in params:
query = query.where('geo', '==', params['geo'])

if 'technology' in params:
params_array = convert_to_array(params['technology'])
query = query.where('technology', 'in', params_array)

if 'rank' in params:
query = query.where('rank', '==', params['rank'])

Expand Down
4 changes: 3 additions & 1 deletion functions/page-weight/libs/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from urllib.parse import unquote

def output(result, headers={}):
status = 200 if result.success() else 400
Expand All @@ -13,5 +14,6 @@ def convert_to_hashes(arr):
return hashes_arr

def convert_to_array(data_string):
list = data_string.split(',')
decoded_data = unquote(data_string)
list = decoded_data.split(',')
return list
4 changes: 3 additions & 1 deletion functions/technologies/libs/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from urllib.parse import unquote

def output(result, headers={}):
status = 200 if result.success() else 400
Expand All @@ -13,5 +14,6 @@ def convert_to_hashes(arr):
return hashes_arr

def convert_to_array(data_string):
list = data_string.split(',')
decoded_data = unquote(data_string)
list = decoded_data.split(',')
return list

0 comments on commit be3d94f

Please sign in to comment.