diff --git a/changedetectionio/conditions/__init__.py b/changedetectionio/conditions/__init__.py index d0c02641..6c66c218 100644 --- a/changedetectionio/conditions/__init__.py +++ b/changedetectionio/conditions/__init__.py @@ -55,7 +55,7 @@ def filter_complete_rules(ruleset): ] return rules -def convert_to_jsonlogic(rule_dict: list): +def convert_to_jsonlogic(logic_operator: str, rule_dict: list): """ Convert a structured rule dict into a JSON Logic rule. @@ -64,9 +64,6 @@ def convert_to_jsonlogic(rule_dict: list): """ - # Determine the logical operator ("ALL" -> "and", "ANY" -> "or") - logic_operator = "and" if rule_dict.get("conditions_match_logic", "ALL") == "ALL" else "or" - json_logic_conditions = [] for condition in rule_dict: @@ -115,6 +112,7 @@ def execute_ruleset_against_all_plugins(current_watch_uuid: str, application_dat ruleset_settings = application_datastruct['watching'].get(current_watch_uuid) if ruleset_settings.get("conditions"): + logic_operator = "and" if ruleset_settings.get("conditions_match_logic", "ALL") == "ALL" else "or" complete_rules = filter_complete_rules(ruleset_settings['conditions']) if complete_rules: # Give all plugins a chance to update the data dict again (that we will test the conditions against) @@ -126,8 +124,10 @@ def execute_ruleset_against_all_plugins(current_watch_uuid: str, application_dat if new_execute_data and isinstance(new_execute_data, dict): EXECUTE_DATA.update(new_execute_data) - ruleset = convert_to_jsonlogic(rule_dict=complete_rules) - result = jsonLogic(logic=ruleset, data=EXECUTE_DATA) + ruleset = convert_to_jsonlogic(logic_operator=logic_operator, rule_dict=complete_rules) + + if not jsonLogic(logic=ruleset, data=EXECUTE_DATA): + result = False return result diff --git a/changedetectionio/conditions/default_plugin.py b/changedetectionio/conditions/default_plugin.py index eb0cb004..f248a729 100644 --- a/changedetectionio/conditions/default_plugin.py +++ b/changedetectionio/conditions/default_plugin.py @@ -40,12 +40,13 @@ def add_data(current_watch_uuid, application_datastruct, ephemeral_data): res = {} if 'text' in ephemeral_data: - res['page_text'] = ephemeral_data['text'] + res['page_filtered_text'] = ephemeral_data['text'] # Better to not wrap this in try/except so that the UI can see any errors price = Price.fromstring(ephemeral_data.get('text')) if price and price.amount != None: + # This is slightly misleading, it's extracting a PRICE not a Number.. res['extracted_number'] = float(price.amount) - logger.debug(f"Extracted price result: '{price}' - returning float({res['extracted_number']})") + logger.debug(f"Extracted number result: '{price}' - returning float({res['extracted_number']})") return res