fix: listing-id-mismatch#309
Open
strech345 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
i saw two problems:
[-1,-1].i only make changes by ki. please check if this will fix and work for you.
Bug Explanation & Resolution: Missing Notifications & Soft-Delete Failures
This document explains the root cause and the resolution for the bug where newly scraped listings were stored in the database but logged as "no new listings found," remained visible in the web UI, and never triggered Telegram notifications.
1. Symptoms & Observations
During execution, the following sequence was logged:
Storing 2 new listingsbut immediately follow withNo new listings found?2. The Root Cause
The issue was caused by a mismatch between in-memory listing IDs and the database primary key format.
Mismatch details:
Pipeline Execution Flow (
FredyPipelineExecutioner.js):_findNew: Identifies 2 listings not currently in the database._save: CallsstoreListings(...)to write them to SQLite.deleteListingsById(ids)and removed from the active in-memory array._notify: Dispatches notifications. If the active array is empty, it throws aNoNewListingsWarning(leading to theNo new listings foundlog).The ID Bug (
listingsStorage.js):storeListings, Fredy generates a new randomnanoid()as the database primary keyid, while storing the crawler's original ID (e.g.12345678) in thehashcolumn.item.id.deleteListingsByIdwith the crawler IDs.idcolumn:idcontains thenanoid()rather than12345678, the update statement modified 0 rows.Collateral Bugs:
This same ID mismatch also silently broke:
updateListingDistancetried to update distance byidusing the crawler ID, failing to save distances./listings/listing/12345678), resulting in404 Listing not foundwhen clicked, since the router queries by thenanoid().3. The Solution
The issue has been resolved by mapping the database primary key back onto the in-memory listing object immediately upon insertion.
In
lib/services/storage/listingsStorage.js(storeListingsfunction):Results of the fix:
manually_deleted = 1) and will no longer show up in the UI.4. Geocoding Failure Fallback (-1, -1 Coordinates)
Symptoms:
Listings whose addresses could not be resolved by Nominatim (the geocoding API) were stored with placeholder coordinates of
latitude: -1andlongitude: -1.-1is a valid numerical coordinate, the spatial/area filter (_filterByArea) attempted to check whether the point[-1, -1]fell within the user's geofenced area.[-1, -1]is located in the Gulf of Guinea (off the coast of West Africa), far outside any German geofence. The area filter would therefore incorrectly identify the listing as "outside the area", soft-delete it from the database, and drop it from the array, causing it to be aussortiert (filtered out).The Solution:
We refined the
_geocodemethod inlib/FredyPipelineExecutioner.jsto only assign coordinates to the listing if the geocoding client returned valid, non-placeholder coordinates (not-1). If geocoding fails,latitudeandlongitudeare left asnullorundefined.Since the area filter (
_filterByArea) is designed to skip filtering and keep listings that do not have any coordinates (falling back to manual inspection), these listings are now correctly kept in the pipeline, sent via Telegram, and displayed in the UI, while SQLite stores them as standardNULLvalues instead of the magic-1placeholder.