Skip to content

Commit ce134ea

Browse files
authored
Merge pull request #15 from HTTPArchive/development
New prod version
2 parents c429f8b + be3d94f commit ce134ea

File tree

12 files changed

+40
-23
lines changed

12 files changed

+40
-23
lines changed

functions/adoption/libs/queries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from .result import Result
55
from .utils import convert_to_array
66

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

99
def list_data(params):
1010
ref = DB.collection(u'adoption')
1111

1212
query = ref
13-
print("params", params)
13+
1414
if 'start' in params:
1515
query = query.where('date', '>=', params['start'])
1616
if 'end' in params:

functions/adoption/libs/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from urllib.parse import unquote
23

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

1516
def convert_to_array(data_string):
16-
list = data_string.split(',')
17+
decoded_data = unquote(data_string)
18+
list = decoded_data.split(',')
1719
return list

functions/categories/libs/queries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .result import Result
55
from .utils import convert_to_array
66

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

99
def list_data(params):
1010
ref = DB.collection(u'categories')

functions/categories/libs/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from urllib.parse import unquote
23

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

1516
def convert_to_array(data_string):
16-
list = data_string.split(',')
17+
decoded_data = unquote(data_string)
18+
list = decoded_data.split(',')
1719
return list

functions/cwvtech/libs/queries.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@
22
import json
33
from google.cloud import firestore
44
from .result import Result
5+
from .utils import convert_to_array
56

6-
DB = firestore.Client(project=os.environ.get('PROJECT'))
7+
DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))
78

89
def list_data(params):
910
ref = DB.collection(u'core_web_vitals')
1011

1112
query = ref
12-
print("params", params)
13+
1314
if 'start' in params:
1415
query = query.where('date', '>=', params['start'])
1516
if 'end' in params:
1617
query = query.where('date', '<=', params['end'])
17-
18+
1819
if 'geo' in params:
19-
if params['geo'] != 'ALL':
20-
query = query.where('geo', '==', params['geo'])
20+
query = query.where('geo', '==', params['geo'])
21+
2122
if 'technology' in params:
22-
query = query.where('technology', '==', params['technology'])
23+
params_array = convert_to_array(params['technology'])
24+
query = query.where('technology', 'in', params_array)
25+
2326
if 'rank' in params:
2427
query = query.where('rank', '==', params['rank'])
2528

functions/cwvtech/libs/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from urllib.parse import unquote
23

34
def output(result, headers={}):
45
status = 200 if result.success() else 400
@@ -11,3 +12,8 @@ def convert_to_hashes(arr):
1112
hash_dict = {inner_arr[0]: inner_arr[1]}
1213
hashes_arr.append(hash_dict)
1314
return hashes_arr
15+
16+
def convert_to_array(data_string):
17+
decoded_data = unquote(data_string)
18+
list = decoded_data.split(',')
19+
return list

functions/lighthouse/libs/queries.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .result import Result
55
from .utils import convert_to_array
66

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

99
def list_data(params):
1010

@@ -19,9 +19,7 @@ def list_data(params):
1919
if 'end' in params:
2020
query = query.where('date', '<=', params['end'])
2121

22-
if params['geo'] != 'ALL':
23-
query = query.where('geo', '==', params['geo'])
24-
22+
query = query.where('geo', '==', params['geo'])
2523
query = query.where('rank', '==', params['rank'])
2624
query = query.where('technology', '==', technology)
2725

functions/lighthouse/libs/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from urllib.parse import unquote
23

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

1516
def convert_to_array(data_string):
16-
list = data_string.split(',')
17+
decoded_data = unquote(data_string)
18+
list = decoded_data.split(',')
1719
return list

functions/page-weight/libs/queries.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .result import Result
55
from .utils import convert_to_array
66

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

99
def list_data(params):
1010
ref = DB.collection(u'page_weight')
@@ -17,9 +17,11 @@ def list_data(params):
1717
query = query.where('date', '<=', params['end'])
1818
if 'geo' in params:
1919
query = query.where('geo', '==', params['geo'])
20+
2021
if 'technology' in params:
2122
params_array = convert_to_array(params['technology'])
2223
query = query.where('technology', 'in', params_array)
24+
2325
if 'rank' in params:
2426
query = query.where('rank', '==', params['rank'])
2527

functions/page-weight/libs/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from urllib.parse import unquote
23

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

1516
def convert_to_array(data_string):
16-
list = data_string.split(',')
17+
decoded_data = unquote(data_string)
18+
list = decoded_data.split(',')
1719
return list

0 commit comments

Comments
 (0)