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 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));
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. */
+4 -1
View File
@@ -173,12 +173,15 @@ export interface ReferenceSystemRecord {
securityStatus: number;
securityClass: string | null;
}
export type ReferenceStationEvidence = 'verified' | 'system_listed';
export interface ReferenceStationRecord {
id: number;
systemId: number;
systemName: string | 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;
name: string | null;
typeId: number | null;