Skip to content

Commit 5da3962

Browse files
warn on different links from same platform
1 parent 04754ae commit 5da3962

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/solesearch_api/tasks/db/base.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logfire
22
from sqlmodel import Session, select
33

4+
from solesearch_api.models.enums import Platform
45
from solesearch_api.models.sneaker import Sneaker
56
from solesearch_api.db import engine
67

@@ -63,9 +64,20 @@ def create_or_update_sneaker(
6364
)
6465

6566
# Add any new links
66-
existing_link_urls = {link.url for link in existing_sneaker.links}
67-
for link in sneaker.links:
68-
if link.url not in existing_link_urls:
67+
existing_links = {
68+
link.platform: link.url for link in existing_sneaker.links
69+
}
70+
for platform, link in sneaker.links.items():
71+
if existing_links.get(platform) == link.url:
72+
logfire.warning(
73+
f"{sneaker.brand} SKU '{sneaker.sku}' already has a link for {platform}",
74+
sneaker_id=existing_sneaker.id,
75+
sneaker_sku=sneaker.sku,
76+
sneaker_brand=sneaker.brand,
77+
existing_link=existing_links[platform],
78+
new_link=link.url,
79+
)
80+
else:
6981
link.sneaker = existing_sneaker
7082
existing_sneaker.links.append(link)
7183

0 commit comments

Comments
 (0)