Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use new .get_probability() from zyte-common-items==0.12.0 #7

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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