From a34b8cfd8119b666ca58f41cc19f6622ae303376 Mon Sep 17 00:00:00 2001 From: Kieran Klukas Date: Thu, 26 Mar 2026 15:53:13 -0400 Subject: [PATCH] feat: filter empty stations --- api/src/gasbuddy.ts | 26 ++++++++++++++------------ gastrack/Services/StationStore.swift | 4 +--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/api/src/gasbuddy.ts b/api/src/gasbuddy.ts index 81ecbe7..0a43fa2 100644 --- a/api/src/gasbuddy.ts +++ b/api/src/gasbuddy.ts @@ -171,18 +171,20 @@ async function graphqlPost( function mapResults(loc: GraphQLResponse["data"]["locationBySearchTerm"]): Station[] { const now = Date.now(); - return loc.stations.results.map((r) => ({ - id: r.id, - name: r.name, - lat: r.latitude ?? loc.latitude, - lng: r.longitude ?? loc.longitude, - address: r.address.line1 || null, - city: r.address.locality || null, - state: r.address.region || null, - zip: r.address.postalCode.trim() || null, - prices: mapPrices(r.prices), - fetchedAt: now, - })); + return loc.stations.results + .map((r) => ({ + id: r.id, + name: r.name, + lat: r.latitude ?? loc.latitude, + lng: r.longitude ?? loc.longitude, + address: r.address.line1 || null, + city: r.address.locality || null, + state: r.address.region || null, + zip: r.address.postalCode.trim() || null, + prices: mapPrices(r.prices), + fetchedAt: now, + })) + .filter((s) => s.prices.some((p) => p.formattedPrice !== null)); } function mapPrices(entries: GasBuddyPriceEntry[]): Price[] { diff --git a/gastrack/Services/StationStore.swift b/gastrack/Services/StationStore.swift index 09d96c8..5e7e967 100644 --- a/gastrack/Services/StationStore.swift +++ b/gastrack/Services/StationStore.swift @@ -9,9 +9,7 @@ final class StationStore: ObservableObject { @Published private(set) var byId: [String: Station] = [:] func merge(_ stations: [Station]) { - for s in stations where s.prices.contains(where: { $0.formattedPrice != nil }) { - byId[s.id] = s - } + for s in stations { byId[s.id] = s } } // Filtered + sorted by distance from a coordinate. -- 2.51.2