From be625644c5b85f36291bf703fc34e0d1be070e0f Mon Sep 17 00:00:00 2001 From: jbaudet-pass <187622442+jbaudet-pass@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:37:52 +0100 Subject: [PATCH] fixup: script --- .../scripts/clean_offer_titles_with_eans/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/src/pcapi/scripts/clean_offer_titles_with_eans/main.py b/api/src/pcapi/scripts/clean_offer_titles_with_eans/main.py index a7244da0eb9..f5be1714eba 100644 --- a/api/src/pcapi/scripts/clean_offer_titles_with_eans/main.py +++ b/api/src/pcapi/scripts/clean_offer_titles_with_eans/main.py @@ -55,6 +55,8 @@ 'SUPPORT_PHYSIQUE_MUSIQUE_CD', 'SUPPORT_PHYSIQUE_MUSIQUE_VINYLE' ) + LIMIT + 1000 ) offer_sub_query LEFT JOIN product on product."jsonData"->>'ean' = offer_sub_query.ean @@ -100,16 +102,21 @@ def get_offers_with_ean_inside_title() -> Collection[OfferEanQueryRow]: def run() -> None: + count = 0 + while True: + print(f"start loop #{count}...") rows = get_offers_with_ean_inside_title() if not rows: break parse_offers(rows) + count += 1 def parse_offers(rows: Collection[OfferEanQueryRow]) -> None: - for chunk in get_chunks(rows, chunk_size=100): + for idx, chunk in enumerate(get_chunks(rows, chunk_size=100)): + print(f"[parse offers][{idx}]...") unknown_offer_rows = [] gcu_incompatible_offer_rows = [] @@ -127,6 +134,8 @@ def parse_offers(rows: Collection[OfferEanQueryRow]) -> None: reject_offers(gcu_incompatible_offer_rows) update_legit_offers(legit_offer_rows) + print(f"[parse offers][{idx}]...done: {len(chunk)} offers.") + @atomic() def update_legit_offers(offer_rows: Collection[OfferEanQueryRow]) -> None: