mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
feat(places): record which search result was picked, on this instance only
The corpus behind "is our own index good enough to replace Nominatim". When somebody searches and then picks a result, the client posts the query, the rank and the pick. Nothing else: no user, no trip, no session, and coordinates only to three decimals. Deliberately decoupled from the search endpoint. Correlating a response with a later pick would mean handing out a ticket on POST /api/maps/search and threading it through all fifteen call sites; the client already holds everything the row needs at the moment of the pick. Evaluation happens offline afterwards: export the corpus, run it against a candidate index, count how often the pick came back in the top five. That is why collection can start before such an index exists, which is the whole point, because the corpus needs weeks of real use and the index needs a server, and those two waits should not be serial. Off unless an admin switches it on, and it reads === 'true' rather than !== 'false'. The three older places switches fail open because a migration backfilled a row for installs already using them; nothing uses this one, so an instance that upgrades and never visits the admin panel logs nothing. Reading is admin only, retention is 180 days, and the switch state is on the unauthenticated app-config endpoint on purpose: whether an instance records what its users search for is something a visitor may know before logging in.
This commit is contained in:
@@ -4257,6 +4257,41 @@ function runMigrations(db: Database.Database): void {
|
||||
db.exec('ALTER TABLE journey_entries ADD COLUMN stats_excluded INTEGER NOT NULL DEFAULT 0');
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Place shadow log: which search result a user actually picked.
|
||||
*
|
||||
* The corpus behind "would our own index have found that too". No user id,
|
||||
* no trip, no session and no result list — the evaluation compares a query
|
||||
* against a pick, and anything beyond that would be collecting for its own
|
||||
* sake on an instance that promises not to.
|
||||
*
|
||||
* The table is created regardless of the switch: the switch decides whether
|
||||
* rows are written, and a schema that appears only when a feature is
|
||||
* enabled is a schema that differs between installs.
|
||||
*
|
||||
* Appended LAST: the array is index-addressed against schema_version.
|
||||
*/
|
||||
() => {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS place_shadow_picks (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
query TEXT NOT NULL,
|
||||
lang TEXT,
|
||||
bias_lat REAL,
|
||||
bias_lng REAL,
|
||||
source TEXT NOT NULL,
|
||||
live_rank INTEGER NOT NULL,
|
||||
live_count INTEGER NOT NULL,
|
||||
picked_name TEXT NOT NULL,
|
||||
picked_lat REAL NOT NULL,
|
||||
picked_lng REAL NOT NULL,
|
||||
picked_place_id TEXT
|
||||
)
|
||||
`);
|
||||
// Retention deletes by age, the export pages by id.
|
||||
db.exec('CREATE INDEX IF NOT EXISTS idx_place_shadow_created ON place_shadow_picks(created_at)');
|
||||
},
|
||||
];
|
||||
|
||||
if (currentVersion < migrations.length) {
|
||||
|
||||
Reference in New Issue
Block a user