Skip to content

Commit a086b40

Browse files
committed
test: testing gh action
1 parent 33ae5a4 commit a086b40

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

infra/batch/datasets/main.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def upload_dataset(url, bucket_name, stable_id):
5151
timestamp_blob = bucket.blob(f"{stable_id}/{timestamp}.zip")
5252
timestamp_blob.upload_from_string(content)
5353
return file_md5_hash, timestamp_blob.public_url
54-
return None, None
54+
return file_md5_hash, None
5555

5656

5757
def create_bucket(bucket_name):
@@ -105,26 +105,25 @@ def batch_dataset(request):
105105
feed_id = result[2]
106106
try:
107107
md5_file_hash, hosted_url = upload_dataset(producer_url, bucket_name, stable_id)
108-
if md5_file_hash is not None:
109-
continue
108+
110109
# Set up transaction for SQL updates
111110
connection = engine.connect()
112111
transaction = connection.begin()
113112

114113
# Create a new version of the dataset in the database
115114
select_dataset_statement = text(f"select id, hash from gtfsdataset where latest=true and feed_id='{feed_id}'")
116115
dataset_results = connection.execute(select_dataset_statement).all()
117-
dataset_id = dataset_results[0][0]
118-
dataset_hash = dataset_results[0][1]
116+
dataset_id = dataset_results[0][0] if len(dataset_results) > 0 else None
117+
dataset_hash = dataset_results[0][1] if len(dataset_results) > 0 else None
119118

120119
# Set the previous version latest field to false
121120
if dataset_hash is not None:
122121
sql_statement = f"update gtfsdataset set latest=false where id='{dataset_id}'"
123122
connection.execute(text(sql_statement))
124123

125-
sql_statement = f"insert into gtfsdataset (id, feed_id, latest, bounding_box, hosted_url, note, hash, " \
124+
sql_statement = f"insert into gtfsdataset (id, feed_id, latest, bounding_box, note, hash, " \
126125
f"download_date, stable_id, hosted_url) " \
127-
f"select '{str(uuid.uuid4())}', feed_id, true, bounding_box, hosted_url, note, " \
126+
f"select '{str(uuid.uuid4())}', feed_id, true, bounding_box, note, " \
128127
f"'{md5_file_hash}', NOW(), stable_id, '{hosted_url}' from " \
129128
f"gtfsdataset where id='{dataset_id}'"
130129

0 commit comments

Comments
 (0)