Best Value: one price age instead of a source breakdown

Dated pricing had crowded More info and the station rows, and most of the
extra copy described a distinction the data cannot make: every station
carries a single station-wide timestamp, so "grade-specific vs
station-wide" never varied in practice.

- More info shows one row, "Price updated 28h ago" (or "Not provided"),
  replacing the separate station-report and fuel-update-time rows and the
  blanket "price freshness is not confirmed" label.
- Rows and the detail sheet stay quiet when a saving is shown; only an
  ineligible comparison explains itself. Provisional savings already read
  as estimates from the capsule, so the fuel-named warning lines are gone.
- Freshness/eligibility logic is unchanged: it still gates the baseline and
  still supports grade-specific timestamps for when the relay emits them.
- Tests updated; localisation keys for the removed copy dropped.
This commit is contained in:
FuelBoard Contributor
2026-10-15 22:00:48 +01:00
parent 5c0458dbf6
commit 5f3051aed7
4 changed files with 44 additions and 64 deletions
+16 -27
View File
@@ -34,15 +34,13 @@ enum FuelPriceFreshness {
recommendationEligibility == .eligible
}
var stationReportAgeLabel: String? {
guard source == .stationWide, let age else { return nil }
return String(format: String(localized: "%@ ago", comment: "Price age, e.g. 28h ago"),
Self.ageText(age))
}
var selectedFuelUpdateLabel: String {
guard source == .gradeSpecific, let age else {
return String(localized: "Not provided", comment: "Fuel-specific update time is missing")
/// The one age More info reports. Production data carries a single
/// station-wide timestamp per station, so there is no separate
/// grade-level age to show; an absent or unreadable timestamp reads
/// "Not provided" rather than implying freshness.
var updateAgeLabel: String {
guard let age else {
return String(localized: "Not provided", comment: "Price update time is missing")
}
return String(format: String(localized: "%@ ago", comment: "Price age, e.g. 28h ago"),
Self.ageText(age))
@@ -118,33 +116,24 @@ enum FuelPriceFreshness {
FuelPriceFreshness.comparisonConfidence(station: station, fuel: fuel, baseline: baseline, now: now)
}
/// Only an ineligible comparison needs a line of its own. The capsule
/// already presents a provisional saving as an estimate, so a second
/// line saying so crowded the rows and the detail sheet without
/// changing anything the user could do.
var warningText: String? {
switch self {
case .verified: return nil
case .provisional: return String(localized: "Price not individually dated — saving is an estimate.")
case .verified, .provisional: return nil
case .ineligible: return String(localized: "Price age unavailable or too old — not a Best Value recommendation.")
}
}
}
/// A short line for a comparison that cannot be recommended at all; rows
/// stay quiet otherwise. Naming the fuel, and which side of the comparison
/// was weak, was noise once the saving is already labelled an estimate.
static func comparisonWarning(station: FuelStation, fuel: FuelType,
baseline: FuelStation?, now: Date = Date()) -> String? {
let confidence = comparisonConfidence(station: station, fuel: fuel, baseline: baseline, now: now)
guard confidence == .provisional, let baseline else { return confidence.warningText }
let candidate = assessment(for: station, fuel: fuel, now: now)
let reference = assessment(for: baseline, fuel: fuel, now: now)
let candidateNeedsWarning = candidate.confidence != .verified || candidate.status != .fresh
let cause = candidateNeedsWarning ? candidate : reference
if cause.source == .stationWide {
let format = candidateNeedsWarning
? String(localized: "Estimated saving · %@ price not individually dated")
: String(localized: "Estimated saving · closest eligible station's %@ price not individually dated")
return String(format: format, fuel.displayName)
}
let format = candidateNeedsWarning
? String(localized: "Estimated saving · %@ price over 7 days old")
: String(localized: "Estimated saving · closest eligible station's %@ price over 7 days old")
return String(format: format, fuel.displayName)
comparisonConfidence(station: station, fuel: fuel, baseline: baseline, now: now).warningText
}
static func comparisonConfidence(station: FuelStation, fuel: FuelType,