fix(reference): classify station evidence
This commit is contained in:
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -32,8 +32,8 @@ test('reference readers search normalized types and expose group/category/system
|
||||
const stations = await reader.stations({ systemId: 30000142 });
|
||||
expect(stations).toHaveLength(2);
|
||||
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: 60003761, systemId: 30000142, systemName: 'Jita', regionId: 10000001, sourceVerified: false, name: null, typeId: null, ownerId: null, x: null, y: null, z: null },
|
||||
{ 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, 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]]);
|
||||
const pinned = reader.pin();
|
||||
|
||||
Reference in New Issue
Block a user