Skip to content

Commit

Permalink
fixup: script
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaudet-pass committed Jan 23, 2025
1 parent 9e5bc3f commit be62564
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion api/src/pcapi/scripts/clean_offer_titles_with_eans/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand All @@ -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:
Expand Down

0 comments on commit be62564

Please sign in to comment.