From a1feda5a21c120e045a922bf6a8575f5dfd5dc68 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 8 Dec 2022 22:18:18 +0100 Subject: [PATCH] Re #1207 - Dont scan for ldjson data when 'no' was clicked on the suggestion --- .../blueprint/price_data_follower/__init__.py | 7 +++++-- changedetectionio/fetch_site_status.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changedetectionio/blueprint/price_data_follower/__init__.py b/changedetectionio/blueprint/price_data_follower/__init__.py index 2c420618..835e8a77 100644 --- a/changedetectionio/blueprint/price_data_follower/__init__.py +++ b/changedetectionio/blueprint/price_data_follower/__init__.py @@ -4,6 +4,9 @@ from flask import Blueprint, flash, redirect, url_for from flask_login import login_required from changedetectionio.store import ChangeDetectionStore +PRICE_DATA_TRACK_ACCEPT = 'accepted' +PRICE_DATA_TRACK_REJECT = 'rejected' + def construct_blueprint(datastore: ChangeDetectionStore): price_data_follower_blueprint = Blueprint('price_data_follower', __name__) @@ -11,14 +14,14 @@ def construct_blueprint(datastore: ChangeDetectionStore): @login_required @price_data_follower_blueprint.route("//accept", methods=['GET']) def accept(uuid): - datastore.data['watching'][uuid]['track_ldjson_price_data'] = 'accepted' + datastore.data['watching'][uuid]['track_ldjson_price_data'] = PRICE_DATA_TRACK_ACCEPT return redirect(url_for("form_watch_checknow", uuid=uuid)) @login_required @price_data_follower_blueprint.route("//reject", methods=['GET']) def reject(uuid): - datastore.data['watching'][uuid]['track_ldjson_price_data'] = 'rejected' + datastore.data['watching'][uuid]['track_ldjson_price_data'] = PRICE_DATA_TRACK_REJECT return redirect(url_for("index")) diff --git a/changedetectionio/fetch_site_status.py b/changedetectionio/fetch_site_status.py index 5397fbb0..2a08b42f 100644 --- a/changedetectionio/fetch_site_status.py +++ b/changedetectionio/fetch_site_status.py @@ -5,6 +5,7 @@ import re import urllib3 from changedetectionio import content_fetcher, html_tools +from changedetectionio.blueprint.price_data_follower import PRICE_DATA_TRACK_ACCEPT, PRICE_DATA_TRACK_REJECT urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) @@ -148,7 +149,7 @@ class perform_site_check(): ) # Inject a virtual LD+JSON price tracker rule - if watch.get('track_ldjson_price_data'): + if watch.get('track_ldjson_price_data', '') == PRICE_DATA_TRACK_ACCEPT: include_filters_rule.append(html_tools.LD_JSON_PRODUCT_OFFER_SELECTOR) has_filter_rule = include_filters_rule and len("".join(include_filters_rule).strip())