Skip to content

Commit

Permalink
use new .get_probability() from zyte-common-items==0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnzZ committed Oct 27, 2023
1 parent 755dbd8 commit 0c97bee
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"scrapy-poet>=0.16.0",
"scrapy-spider-metadata>=0.1.2",
"scrapy-zyte-api[provider]>=0.12.2",
"zyte-common-items>=0.8.0",
"zyte-common-items>=0.12.0",
],
classifiers=[
"Development Status :: 3 - Alpha",
Expand Down
6 changes: 1 addition & 5 deletions zyte_spider_templates/spiders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ def get_parse_navigation_request(
)

def get_parse_product_request_priority(self, request: ProbabilityRequest) -> int:
# TODO: Simplify when https://github.com/zytedata/zyte-common-items/pull/64 is released
probability = 0
if metadata := getattr(request, "metadata", None):
probability = metadata.probability
return int(100 * probability) + self._NEXT_PAGE_PRIORITY
return int(100 * request.get_probability()) + self._NEXT_PAGE_PRIORITY

def get_parse_product_request(
self, request: ProbabilityRequest, callback: Optional[Callable] = None
Expand Down
4 changes: 1 addition & 3 deletions zyte_spider_templates/spiders/ecommerce.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ def parse_navigation(
def parse_product(
self, response: DummyResponse, product: Product
) -> Iterable[Product]:
probability = None
if metadata := getattr(product, "metadata", None):
probability = metadata.probability
probability = product.get_probability()

# TODO: convert to a configurable parameter later on after the launch
if probability is None or probability >= 0.1:
Expand Down

0 comments on commit 0c97bee

Please sign in to comment.