Skip to content

Commit

Permalink
Merge pull request #7 from zytedata/get_probabilities
Browse files Browse the repository at this point in the history
use new `.get_probability()` from zyte-common-items==0.12.0
  • Loading branch information
kmike authored Oct 27, 2023
2 parents 755dbd8 + c80e3f4 commit d04289b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 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
5 changes: 1 addition & 4 deletions zyte_spider_templates/spiders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +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
probability = request.get_probability() or 0
return int(100 * probability) + self._NEXT_PAGE_PRIORITY

def get_parse_product_request(
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 d04289b

Please sign in to comment.