Skip to content

Commit

Permalink
fix: first sync v2 with method data_processor.process_single_sku
Browse files Browse the repository at this point in the history
  • Loading branch information
elitonzky committed Dec 13, 2024
1 parent 19f34a1 commit affe25d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions marketplace/services/vtex/utils/data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,28 +179,38 @@ def _process_queue_without_threads(self):

def worker(self):
"""
Processes items from the queue. For v2 (use_sync_v2), processes `seller_id` and `sku_id`.
For v1, processes only `sku_id`.
Processes items from the queue.
- For v2 (`use_sync_v2`) with `update_product=True`
(for example, batch uploads), processes items as `seller_id` and `sku_id` pairs.
- For v1 or initial sync (`update_product=False`), processes only `sku_id` with default seller combinations.
The method dynamically determines the appropriate processing logic
based on the `use_sync_v2` flag and the context (`update_product`).
"""
while not self.queue.empty():
try:
# Extract item from the queue
item = self.queue.get()

# Determine processing logic based on use_sync_v2
if self.use_sync_v2:
# Determine processing logic based on `use_sync_v2` and `update_product`
if self.use_sync_v2 and self.update_product:

Check warning on line 198 in marketplace/services/vtex/utils/data_processor.py

View check run for this annotation

Codecov / codecov/patch

marketplace/services/vtex/utils/data_processor.py#L198

Added line #L198 was not covered by tests
# Parse `seller_id` and `sku_id` pair for v2 batch uploads
seller_id, sku_id = self._parse_seller_sku(item)
processing_result = self.process_seller_sku(
seller_id=seller_id, sku_id=sku_id
)
else:
processing_result = self.process_single_sku(item)
# Process `sku_id` for v1 or first sync
processing_result = self.process_single_sku(sku_id=item)

Check warning on line 206 in marketplace/services/vtex/utils/data_processor.py

View check run for this annotation

Codecov / codecov/patch

marketplace/services/vtex/utils/data_processor.py#L206

Added line #L206 was not covered by tests

# Handle the result and update the state
# Handle the processing result (e.g., add to results, update progress bar)
self._handle_processing_result(processing_result)

except Exception as e:
print(f"Error processing item: {item}. Details: {str(e)}")
# Log any processing errors and continue
print(f"Error processing item {item}: {str(e)}")

Check warning on line 213 in marketplace/services/vtex/utils/data_processor.py

View check run for this annotation

Codecov / codecov/patch

marketplace/services/vtex/utils/data_processor.py#L213

Added line #L213 was not covered by tests
with self.progress_lock:
self.invalid_products_count += 1
self.progress_bar.set_description(
Expand Down

0 comments on commit affe25d

Please sign in to comment.