Repository navigation
fix(wggesucht): mark the Gesamtmiete as a rent with the charges in it - #526
Conversation
orangecoding
left a comment
There was a problem hiding this comment.
Thanks, the diagnosis is right and the provider change itself is fine. Two things before this can go in, see the inline comments: the stored charges go stale on a price change, and existing listings are left on the old reading.
| ...listing, | ||
| address: address || listing.address, | ||
| description: fullDescription, | ||
| ...(charges != null ? { charges } : {}), |
There was a problem hiding this comment.
charges is the difference to the Gesamtmiete at the time the listing was stored. WG-Gesucht is price tracked, and applyPriceChange in listingsStorage.js only updates price. After a change from 1400 to 1300 the row still says charges: 250, so the rent card shows a cold rent of 1050 as "listed rent minus stated charges", a figure the advert never stated. The invariant from the JSDoc of readCharges breaks on the first price change.
Simplest fix I see: clear charges in applyPriceChange for rows with charges_included = 1. The card then falls back to "included, not stated separately", which is true. Please add a test for it.
There was a problem hiding this comment.
Done: applyPriceChange clears charges when charges_included = 1, with a test.
AI found a potential side effect. I can't yet tell how much code that would be, but sounds like a reasonable change, not sure if for this PR or a new one as a follow up?
One side effect: nothing fills charges back in, so after the first price change the cold rent is gone for good, and the listing no longer matches an immowelt Kaltmiete. I can follow up by having the price tracker read the Miete as well, if you'd like.
| title: o.title || '', | ||
| price: extractNumber(o.price), | ||
| // The search list shows the Gesamtmiete, the rent with the Nebenkosten in it. | ||
| chargesIncluded: true, |
There was a problem hiding this comment.
Rows already stored keep charges_included NULL and are still read as a Kaltmiete, so the bug from the description stays for every WG-Gesucht listing a user already has. One job then shows both readings side by side, and the affordability filter puts them into different bands.
The list price was the Gesamtmiete before the relaunch too, so a backfill is safe. Please add a migration: UPDATE listings SET charges_included = 1 WHERE provider = 'wgGesucht' AND charges_included IS NULL.
There was a problem hiding this comment.
Added migration 59 with your SQL, plus a test.
AI found a potential side effect. Sounds valid to me. I did not check the code path myself. I assume it depends on the version/update compatibility guarantees of fredy. (e.g. if only update by one major version is supported, then I assume this is not a valid finding?)
One caveat: from 25.0.0 to 29.2.2 the price tracker stored the Miete as the price (fixed in f64a9eb). Rows that went offline or were deleted in that window still hold the Miete, so the backfill marks them warm and they look cheaper than they are. I could skip WG-Gesucht rows whose latest price-history entry is a priceProbe from before 2026-10-16. Should I, or keep it simple?
|
@Manuelraa still interested in this? |
|
Hi thanks for merging the other PR. Yes I am. I have been (and still) are traveling a lot since opening this. I plan to address the comments this weekend. Sorry for the delay. |
WG-Gesucht's result cards quote the Gesamtmiete, and the provider stored it as the price without setting chargesIncluded. Fredy reads such a price as the Kaltmiete, so the listing view showed a 1.400 EUR Gesamtmiete as a 1.400 EUR cold rent, added estimated Nebenkosten on top, and judged its affordability against the cold ceilings. Every WG-Gesucht listing is now marked chargesIncluded. Where the exposé's "Kosten" panel states Nebenkosten or Sonstige Kosten, the detail page, and an advert added by its URL, also fill in charges as the Gesamtmiete less the Miete stated there, so the cold rent shown is the advert's own Miete. With both "n.a." the charges stay unknown rather than 0, since such a Miete is often all-inclusive. The price stays the Gesamtmiete, which keeps the hash and the price tracking as they were. Checked against a live advert (wohnungen-in-Mannheim-Innenstadt.6184990, Miete 1150 EUR, Gesamtmiete 1400 EUR): price 1400, charges 250. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e changes A rent quoted with the charges in it keeps its charges as a share of that price. A price change moved only the price, so after 1400 to 1300 a stored 250 turned into a cold rent of 1050 the advert never stated. The charges of such a row are now cleared with the move, and the rent reads as charges included but not stated separately, which stays true. Charges stated beside a cold rent are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the charges Rows stored before the provider set chargesIncluded kept a NULL basis and were still read as a Kaltmiete, so one job showed the old and the new WG-Gesucht rents side by side under two readings, and the affordability filter put them into different bands. The list price was the Gesamtmiete before the relaunch too, so a migration marks every such row. Their charges stay unknown, since they were never read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
455dab9 to
1919f02
Compare
|
Thanks! |
What does this PR do?
WG-Gesucht's result cards quote the Gesamtmiete, but the provider stored it as
pricewithoutchargesIncluded, so Fredy read it as the Kaltmiete: the listing view showed a 1.400 € Gesamtmiete as a 1.400 € cold rent, added estimated Nebenkosten on top, and checked affordability against the cold ceilings.Every WG-Gesucht listing is now marked chargesIncluded: true. When the exposé's "Kosten" panel states Nebenkosten or Sonstige Kosten, the detail page (and "Add listing" by URL) also sets charges to the Gesamtmiete minus the Miete, so the cold rent shown is the advert's own Miete. Otherwise charges stays empty instead of 0. price stays the Gesamtmiete, so the hash and the price tracking are unchanged and no listing is stored twice.
Checked against a live advert (
/wohnungen-in-Mannheim-Innenstadt.6184990.html, Miete 1.150 €, Gesamtmiete 1.400 €):price1400,charges250.The "Miete:" label is matched on the German page, like the provider's other label matches (the price tracking's "Gesamtmiete"). On a search under
/en/or/es/the listings are still markedchargesIncluded, andchargesstays empty.Migration 59 marks existing WG-Gesucht listings as charges_included. A price change clears their stored charges.
Related issue
none
AI disclosure (required)
ai:none- I wrote this myself. No AI generated code, text or commit messages.ai:assisted- AI helped with parts of it (autocomplete, refactoring, tests, docs). I reviewed and understand every line.ai:generated- AI produced most or all of this PR. I reviewed it, but it is largely machine written.Which AI: Claude Code, Claude Opus 5.5
How much: the whole diff (provider change and tests), the commit message and this description. I noticed a WG-Gesucht listing whose Gesamtmiete Fredy showed as the base rent.
Why: tracing how Fredy treats a rent with and without
chargesIncludedacross the provider, the storage and the rent card was quicker with the agent.Checklist
yarn test:offlinepasses (oryarn testif the change touches a live provider)yarn lintandyarn format:checkpass