Skip to content

Commit 2714db9

Browse files
committed
Reduce debug logging for product search
1 parent 67b9033 commit 2714db9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/python_picnic_api2/helper.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ def _extract_search_results(raw_results, max_items: int = 10):
9191
search"""
9292
search_results = []
9393

94+
LOGGER.debug(f"Extracting search results from {raw_results}")
95+
9496
def find_articles(node):
95-
LOGGER.debug(f"Searching for products in {node}")
9697
if len(search_results) >= max_items:
9798
return
9899

99100
content = node.get("content", {})
100101
if content.get("type") == "SELLING_UNIT_TILE" and "sellingUnit" in content:
101102
selling_unit = content["sellingUnit"]
102-
sole_article_ids = SOLE_ARTICLE_ID_PATTERN.findall(
103-
json.dumps(node))
103+
sole_article_ids = SOLE_ARTICLE_ID_PATTERN.findall(json.dumps(node))
104104
sole_article_id = sole_article_ids[0] if sole_article_ids else None
105105
result_entry = {
106106
**selling_unit,
@@ -115,11 +115,9 @@ def find_articles(node):
115115
if "child" in node:
116116
find_articles(node.get("child"))
117117

118-
LOGGER.debug(f"Leaving extraction for node {node}")
119-
120118
body = raw_results.get("body", {})
121119
find_articles(body.get("child", {}))
122120

123-
LOGGER.debug(f"Found {len(search_results)} products after extraction")
121+
LOGGER.debug(f"Found {len(search_results)}/{max_items} products after extraction")
124122

125123
return [{"items": search_results}]

0 commit comments

Comments
 (0)