dgtlmoon / changedetection.io

The best and simplest free open source web page change detection, website watcher, restock monitor and notification service. Restock Monitor, change detection. Designed for simplicity - Simply monitor which websites had a text change for free. Free Open source web page change detection, Website defacement monitoring, Price change notification
https://changedetection.io
Apache License 2.0
16.69k stars 924 forks source link

Apply filters on top of extracted price objects #1608

Closed mrapacz closed 2 weeks ago

mrapacz commented 1 year ago

Describe the bug Was not sure whether to file it as a bug or a feature request, it feels like the 'price tracking' feature is just not complete yet :) (I checked other issues, but haven't found anything directly related to my request)

Currently if you add a certain site and changedetection.io detects price data within it, it will offer to track the price. I just stumbled upon this use case:

  1. Let's say I want to track this product - https://gb.ecco.com/en-GB/product/5642848249/ECCO-SOFT-7-M
  2. I create a check for this product, it runs and I get a prompt to track the price: 1_embedded
  3. I hit yes and it turns out the extracted price object is the following:
{
    "url": "https://gb.ecco.com/en-GB/product/5642848249/ECCO-SOFT-7-M",
    "priceCurrency": "GBP",
    "price": "130",
    "priceValidUntil": "2024-05-30",
    "itemCondition": "NewCondition",
    "availability": "InStock"
}

It turns out the practice of this shop is to update the priceValidUntil every day to <today> + <1 year>. This means that if I were to track this item like this, I'd be getting one notification per day, since the json changes. I'm actually interested in the price part only, though.

  1. If I define a json rule on top of this - let's take jq: .price in this case I get the following:
    null{
    "url": "https://gb.ecco.com/en-GB/product/5642848249/ECCO-SOFT-7-M",
    "priceCurrency": "GBP",
    "price": "130",
    "priceValidUntil": "2024-05-30",
    "itemCondition": "NewCondition",
    "availability": "InStock"
    }

    So it seems like what happens is the software tries to extract .price from the site (which fails and hence null) and then append the extracted price to the output.

Version 0.42.2

To Reproduce

  1. Described the steps above.
  2. Here's the shared watch - https://changedetection.io/share/gfxmTdroijAa

Expected behavior I'd expect the jq/jsonpath filters to work on the extracted price object.

Screenshots If applicable, add screenshots to help explain your problem. This is how the diff looks after adding jq: .price to the watch:

watch

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

dgtlmoon commented 1 year ago

@mrapacz can you write a pytest test case to show it and make a PR? :)

dgtlmoon commented 1 year ago

btw, any difference if you use jq: .price or jq:.price ?

mrapacz commented 1 year ago

btw, any difference if you use jq: .price or jq:.price ?

Nope, same bevahiour!

@mrapacz can you write a pytest test case to show it and make a PR? :)

Sure - if you confirm it's a bug, I'll be happy to draft a test and look into this when I get a moment, though it's a relatively low priority for me atm - I figured I'll follow-up #1495 with a bunch of issues related to things that surprised/bugged me mostly to provide more feedback rather than attempt to address them myself 😅 But I'm happy to contribute as well as much as my availability allows ;)

dgtlmoon commented 1 year ago

@mrapacz I have the same situation - no time to spend on this issue unfortunately, so the only solid way to start is if you can provide a PR with just a pytest to prove it, then I can dive deeper into the architecture etc

dgtlmoon commented 1 month ago

solved in https://github.com/dgtlmoon/changedetection.io/pull/2041

mrapacz commented 2 weeks ago

Confirmed it works now, closing. Thanks!