Skip to content

Commit eea6013

Browse files
committed
technologies script updated to get description from BQ
1 parent 57b91a2 commit eea6013

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

scripts/script_technologies.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ def execute_query_and_insert_result(start_date, end_date):
2727

2828
query = """
2929
SELECT
30-
date,
3130
client,
3231
app AS technology,
33-
# TODO
34-
NULL AS description,
32+
description,
3533
# CSV format
3634
category,
37-
# TODO: other technologies within category?
3835
NULL AS similar_technologies,
3936
origins
4037
FROM
4138
`httparchive.core_web_vitals.technologies`
39+
JOIN
40+
`httparchive.core_web_vitals.technology_descriptions`
41+
ON
42+
app = technology
4243
WHERE
4344
geo = 'ALL' AND
4445
rank = 'ALL'
4546
"""
47+
4648
# Construct the WHERE clause based on the provided parameters
4749
if start_date and end_date:
4850
query += f" AND date >= '{start_date}' AND date <= '{end_date}'"
@@ -56,24 +58,10 @@ def execute_query_and_insert_result(start_date, end_date):
5658
# Create a new Firestore document for each result and insert it into the "technologies" collection
5759
collection_ref = firestore_client.collection(u'technologies')
5860

59-
tech_collection_ref = firestore_client.collection(u'technologies-list')
60-
6161
for row in results:
62-
6362
item = dict(row.items())
64-
65-
# Query the techonologies-list collection for the description
66-
#
67-
tech_query = tech_collection_ref.where('name', '==', row['technology'])
68-
tech_query = tech_query.limit(1)
69-
tech_results = tech_query.stream()
70-
technology = {}
71-
for tech in tech_results:
72-
technology = tech.to_dict()
73-
7463
# overriding BQ fields
7564
item['date'] = str(row['date'])
76-
item['description'] = technology.get('description','')
7765

7866
print(item)
7967

0 commit comments

Comments
 (0)