|
1 | 1 | import os |
2 | | -import json |
3 | 2 | from google.cloud import firestore |
| 3 | +from google.cloud.firestore_v1.base_query import FieldFilter |
4 | 4 | from .result import Result |
5 | 5 | from .utils import convert_to_array |
6 | 6 |
|
7 | 7 | DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE')) |
| 8 | +TABLE = 'lighthouse' |
8 | 9 |
|
9 | 10 | def list_data(params): |
10 | 11 |
|
11 | 12 | technology_array = convert_to_array(params['technology']) |
12 | 13 | data = [] |
13 | 14 |
|
14 | 15 | for technology in technology_array: |
15 | | - query = DB.collection(u'lighthouse') |
| 16 | + query = DB.collection(TABLE) |
16 | 17 |
|
17 | 18 | if 'start' in params: |
18 | | - query = query.where('date', '>=', params['start']) |
| 19 | + query = query.where(filter=FieldFilter('date', '>=', params['start'])) |
19 | 20 | if 'end' in params: |
20 | | - query = query.where('date', '<=', params['end']) |
| 21 | + query = query.where(filter=FieldFilter('date', '<=', params['end'])) |
21 | 22 |
|
22 | | - query = query.where('geo', '==', params['geo']) |
23 | | - query = query.where('rank', '==', params['rank']) |
24 | | - query = query.where('technology', '==', technology) |
| 23 | + query = query.where(filter=FieldFilter('geo', '==', params['geo'])) |
| 24 | + query = query.where(filter=FieldFilter('rank', '==', params['rank'])) |
| 25 | + query = query.where(filter=FieldFilter('technology', '==', technology)) |
25 | 26 |
|
26 | 27 | documents = query.stream() |
27 | 28 |
|
|
0 commit comments