Scope cheapest/RAG/TOP to alert trigger radius in app + widget; header shows 'within X km'; falls back to full fetch when radius pool empty
This commit is contained in:
@@ -84,9 +84,17 @@ struct FuelPriceTimelineProvider: TimelineProvider {
|
||||
FuelStore.saveLocation(lat: location.lat, lng: location.lng)
|
||||
}
|
||||
|
||||
// 3) Load stations, then sort by distance-weighted score.
|
||||
// 3) Load stations, then sort by price (distance tiebreak), scoped to
|
||||
// the alert trigger radius so the widget's "cheapest" matches the app.
|
||||
var stations = FuelStore.loadStations()
|
||||
if stations.isEmpty { stations = SampleFuelProvider.sampleStations }
|
||||
let radiusKM = FuelStore.loadAlertsRadius()
|
||||
if let location {
|
||||
let within = stations.filter {
|
||||
$0.distanceKM(to: location.lat, lng2: location.lng) <= radiusKM
|
||||
}
|
||||
if !within.isEmpty { stations = within }
|
||||
}
|
||||
let filtered = stations.filter { $0.prices[fuel] != nil }
|
||||
let sorted: [FuelStation]
|
||||
if let location {
|
||||
|
||||
Reference in New Issue
Block a user