Skip to content

Commit 851c019

Browse files
committed
Add missing id in the path
1 parent c181316 commit 851c019

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

functions-python/tasks_executor/src/tasks/geojson/update_geojson_files_precision.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def query_unprocessed_feeds(limit, db_session):
6262

6363

6464
@track_metrics(metrics=("time", "memory", "cpu"))
65-
def _upload_file(bucket, geojson):
66-
processed_blob = bucket.blob("geolocation.geojson")
65+
def _upload_file(bucket, file_path, geojson):
66+
processed_blob = bucket.blob(file_path)
6767
processed_blob.upload_from_string(
6868
json.dumps(geojson, ensure_ascii=False),
6969
content_type="application/geo+json",
@@ -163,9 +163,8 @@ def update_geojson_files_precision_handler(
163163
if processed % 100 == 0:
164164
logging.info("Processed %s/%s", processed, len(feeds))
165165
db_session.commit()
166-
file = storage.Blob(
167-
bucket=bucket, name=f"{feed.stable_id}/{GEOLOCATION_FILENAME}"
168-
)
166+
file_path = f"{feed.stable_id}/{GEOLOCATION_FILENAME}"
167+
file = storage.Blob(bucket=bucket, name=file_path)
169168
if not file.exists():
170169
logging.info("File does not exist: %s", file.name)
171170
continue
@@ -181,8 +180,9 @@ def update_geojson_files_precision_handler(
181180

182181
# Optionally upload processed geojson
183182
if not dry_run:
184-
_upload_file(bucket, geojson)
183+
_upload_file(bucket, file_path, geojson)
185184
_update_feed_info(feed, timestamp)
185+
logging.info("Updated feed %s", feed.stable_id)
186186

187187
processed += 1
188188
except Exception as e:

functions-python/tasks_executor/tests/tasks/geojson/test_update_geojson_files_precision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ def test_handler_uploads_and_updates_feed_info(self, db_session: Session):
180180
)
181181

182182
# verify upload happened
183-
self.assertIn("geolocation.geojson", fake_bucket.uploaded)
184-
uploaded_text = fake_bucket.uploaded["geolocation.geojson"]
183+
self.assertIn(blob_name, fake_bucket.uploaded)
184+
uploaded_text = fake_bucket.uploaded[blob_name]
185185
uploaded_geo = json.loads(uploaded_text)
186186
coords = uploaded_geo.get("features")[0]["geometry"]["coordinates"]
187187
self.assertEqual(coords, [round(100.1234567, 5), round(0.9876543, 5)])

0 commit comments

Comments
 (0)