mirror of
https://github.com/tonytins/amtkstat.git
synced 2026-10-24 05:32:54 -04:00
Wired up isDataStale()
If both isStale() and isDataStale() are in an agreement, no train is added to the list.
This commit is contained in:
parent
f8eef909d2
commit
ef98531ca2
1 changed files with 9 additions and 3 deletions
|
|
@ -138,6 +138,7 @@ struct ContentView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
var zoneCache: [String: TimeZone?] = [code: lookup.timeZone]
|
var zoneCache: [String: TimeZone?] = [code: lookup.timeZone]
|
||||||
|
let staleness = await staleTrainLookup()
|
||||||
|
|
||||||
var newRows: [TrainStatusRow] = []
|
var newRows: [TrainStatusRow] = []
|
||||||
for number in lookup.trainNumbers {
|
for number in lookup.trainNumbers {
|
||||||
|
|
@ -151,7 +152,8 @@ struct ContentView: View {
|
||||||
for: train,
|
for: train,
|
||||||
code: code,
|
code: code,
|
||||||
zone: lookup.timeZone,
|
zone: lookup.timeZone,
|
||||||
cache: &zoneCache
|
cache: &zoneCache,
|
||||||
|
staleness: staleness
|
||||||
)
|
)
|
||||||
if let row {
|
if let row {
|
||||||
newRows.append(row)
|
newRows.append(row)
|
||||||
|
|
@ -174,11 +176,15 @@ struct ContentView: View {
|
||||||
for train: Train,
|
for train: Train,
|
||||||
code stationCode: String,
|
code stationCode: String,
|
||||||
zone timeZone: TimeZone?,
|
zone timeZone: TimeZone?,
|
||||||
cache zoneCache: inout [String: TimeZone?]
|
cache zoneCache: inout [String: TimeZone?],
|
||||||
|
staleness: [String: TimeInterval]
|
||||||
) async -> TrainStatusRow? {
|
) async -> TrainStatusRow? {
|
||||||
let leg = train.stations?.first { $0.code == stationCode }
|
let leg = train.stations?.first { $0.code == stationCode }
|
||||||
|
|
||||||
guard !isStale(leg, timeZone: timeZone) else {
|
guard
|
||||||
|
!isStale(leg, timeZone: timeZone) &&
|
||||||
|
!isDataStale(train.trainID, staleness: staleness)
|
||||||
|
else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue