Skip to content

Commit 3bdce28

Browse files
author
Krystle Salazar
committed
Log only the first run of the update
1 parent eaf5fad commit 3bdce28

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

catalog/dags/flickr_thumbs_removal.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,25 @@ def count():
4343

4444
@task()
4545
def delete(num_thumbs):
46+
log_sql = True
4647
if num_thumbs == 0:
4748
logger.info("No Flickr thumbnails found.")
4849

4950
while num_thumbs > 0:
5051
query = dedent(
5152
f"""
52-
UPDATE image SET thumbnail = NULL WHERE identifier IN
53-
(SELECT identifier {select_conditions} FETCH FIRST 10000 ROWS ONLY FOR UPDATE SKIP LOCKED)
53+
UPDATE image SET thumbnail = NULL WHERE identifier IN (
54+
SELECT identifier {select_conditions}
55+
FETCH FIRST 10000 ROWS ONLY FOR UPDATE SKIP LOCKED
56+
)
5457
"""
5558
)
56-
pg.run(query)
59+
pg.run(query, log_sql=log_sql)
5760
num_thumbs -= 10000
5861
logger.info(
5962
f"Flickr thumbnails left: {num_thumbs if num_thumbs > 0 else 0}."
6063
)
64+
log_sql = False
6165

6266
@task()
6367
def report():

0 commit comments

Comments
 (0)