Skip to content

Commit

Permalink
Merge pull request #15 from HTTPArchive/development
Browse files Browse the repository at this point in the history
New prod version
  • Loading branch information
maceto authored Nov 28, 2023
2 parents c429f8b + be3d94f commit ce134ea
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 23 deletions.
4 changes: 2 additions & 2 deletions functions/adoption/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from .result import Result
from .utils import convert_to_array

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

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

query = ref
print("params", params)

if 'start' in params:
query = query.where('date', '>=', params['start'])
if 'end' in params:
Expand Down
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
2 changes: 1 addition & 1 deletion functions/categories/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .result import Result
from .utils import convert_to_array

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

def list_data(params):
ref = DB.collection(u'categories')
Expand Down
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
15 changes: 9 additions & 6 deletions functions/cwvtech/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@
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'))
DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))

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

query = ref
print("params", params)

if 'start' in params:
query = query.where('date', '>=', params['start'])
if 'end' in params:
query = query.where('date', '<=', params['end'])

if 'geo' in params:
if params['geo'] != 'ALL':
query = query.where('geo', '==', params['geo'])
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
6 changes: 2 additions & 4 deletions functions/lighthouse/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .result import Result
from .utils import convert_to_array

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

def list_data(params):

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

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

query = query.where('geo', '==', params['geo'])
query = query.where('rank', '==', params['rank'])
query = query.where('technology', '==', technology)

Expand Down
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
4 changes: 3 additions & 1 deletion functions/page-weight/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .result import Result
from .utils import convert_to_array

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

def list_data(params):
ref = DB.collection(u'page_weight')
Expand All @@ -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
6 changes: 2 additions & 4 deletions functions/technologies/libs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
from .result import Result
from .utils import convert_to_array

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

def list_data(params):
ref = DB.collection(u'technologies')

query = ref
print("params", params)

if 'start' in params:
query = query.where('date', '>=', params['start'])
if 'end' in params:
query = query.where('date', '<=', params['end'])
if 'geo' in params:
if params['geo'] != 'ALL':
query = query.where('geo', '==', params['geo'])
query = query.where('geo', '==', params['geo'])
if 'technology' in params:
params_array = convert_to_array(params['technology'])
query = query.where('technology', 'in', params_array)
Expand Down
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 ce134ea

Please sign in to comment.