fix(reference): classify station evidence

This commit is contained in:
jb
2026-09-19 09:53:46 -04:00
parent 7601365621
commit 18515efbdf
3 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ function queryStations(db: Database, selection: StationSelection): Promise<Refer
const systemId = optionValue(selection, 'systemId'); if (typeof systemId === 'number') { conditions.push('st.system_id = ?'); args.push(systemId); } const systemId = optionValue(selection, 'systemId'); if (typeof systemId === 'number') { conditions.push('st.system_id = ?'); args.push(systemId); }
const query = optionValue(selection, 'query'); if (typeof query === 'string' && query.trim()) { conditions.push("st.name LIKE ? ESCAPE '\\'"); args.push(like(query)); } const query = optionValue(selection, 'query'); if (typeof query === 'string' && query.trim()) { conditions.push("st.name LIKE ? ESCAPE '\\'"); args.push(like(query)); }
const rows = db.query<StationRow, (string | number)[]>(`SELECT st.station_id,st.system_id,s.name AS system_name,c.region_id,st.name,st.type_id,st.owner_id,st.x,st.y,st.z,st.source_verified FROM stations st JOIN systems s ON s.system_id = st.system_id LEFT JOIN constellations c ON c.constellation_id = s.constellation_id${conditions.length ? ` WHERE ${conditions.join(' AND ')}` : ''} ORDER BY st.station_id LIMIT ? OFFSET ?`).all(...args, limit(Number(optionValue(selection, 'limit'))), bounded(Number(optionValue(selection, 'offset')), 0)); const rows = db.query<StationRow, (string | number)[]>(`SELECT st.station_id,st.system_id,s.name AS system_name,c.region_id,st.name,st.type_id,st.owner_id,st.x,st.y,st.z,st.source_verified FROM stations st JOIN systems s ON s.system_id = st.system_id LEFT JOIN constellations c ON c.constellation_id = s.constellation_id${conditions.length ? ` WHERE ${conditions.join(' AND ')}` : ''} ORDER BY st.station_id LIMIT ? OFFSET ?`).all(...args, limit(Number(optionValue(selection, 'limit'))), bounded(Number(optionValue(selection, 'offset')), 0));
return Promise.resolve(rows.map((row) => ({ id: row.station_id, systemId: row.system_id, systemName: row.system_name, regionId: row.region_id, sourceVerified: row.source_verified === 1, name: row.name, typeId: row.type_id, ownerId: row.owner_id, x: row.x, y: row.y, z: row.z }))); return Promise.resolve(rows.map((row) => ({ id: row.station_id, systemId: row.system_id, systemName: row.system_name, regionId: row.region_id, evidence: row.source_verified === 1 ? 'verified' as const : 'system_listed' as const, sourceVerified: row.source_verified === 1, name: row.name, typeId: row.type_id, ownerId: row.owner_id, x: row.x, y: row.y, z: row.z })));
} }
/** Reader construction closes malformed handles before surfacing the schema error. */ /** Reader construction closes malformed handles before surfacing the schema error. */
+4 -1
View File
@@ -173,12 +173,15 @@ export interface ReferenceSystemRecord {
securityStatus: number; securityStatus: number;
securityClass: string | null; securityClass: string | null;
} }
export type ReferenceStationEvidence = 'verified' | 'system_listed';
export interface ReferenceStationRecord { export interface ReferenceStationRecord {
id: number; id: number;
systemId: number; systemId: number;
systemName: string | null; systemName: string | null;
regionId: number | null; regionId: number | null;
/** True only for a station row imported from the authoritative station member. */ /** Evidence distinguishes authoritative station rows from system-list-only IDs. */
evidence: ReferenceStationEvidence;
/** Compatibility projection; true exactly when evidence is `verified`. */
sourceVerified: boolean; sourceVerified: boolean;
name: string | null; name: string | null;
typeId: number | null; typeId: number | null;
+2 -2
View File
@@ -32,8 +32,8 @@ test('reference readers search normalized types and expose group/category/system
const stations = await reader.stations({ systemId: 30000142 }); const stations = await reader.stations({ systemId: 30000142 });
expect(stations).toHaveLength(2); expect(stations).toHaveLength(2);
expect(stations).toEqual([ expect(stations).toEqual([
{ id: 60003760, systemId: 30000142, systemName: 'Jita', regionId: 10000001, sourceVerified: true, name: 'Jita IV - Moon 4 - Caldari Navy Assembly Plant', typeId: 587, ownerId: 1000035, x: 1, y: 2, z: 3 }, { id: 60003760, systemId: 30000142, systemName: 'Jita', regionId: 10000001, evidence: 'verified', sourceVerified: true, name: 'Jita IV - Moon 4 - Caldari Navy Assembly Plant', typeId: 587, ownerId: 1000035, x: 1, y: 2, z: 3 },
{ id: 60003761, systemId: 30000142, systemName: 'Jita', regionId: 10000001, sourceVerified: false, name: null, typeId: null, ownerId: null, x: null, y: null, z: null }, { id: 60003761, systemId: 30000142, systemName: 'Jita', regionId: 10000001, evidence: 'system_listed', sourceVerified: false, name: null, typeId: null, ownerId: null, x: null, y: null, z: null },
]); ]);
expect(await reader.stations({ query: 'assembly' })).toEqual([stations[0]]); expect(await reader.stations({ query: 'assembly' })).toEqual([stations[0]]);
const pinned = reader.pin(); const pinned = reader.pin();