Add TFL train disruption alerts #5
@@ -48,6 +48,11 @@ final class TFLDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
// Severity 4 = Planned Closure, 5 = Part Closure, 10 = Good Service
|
||||
private static let ignoredSeverities: Set<Int> = [4, 5, 10]
|
||||
// Severity 1 = Closed, 2 = Suspended, 3 = Part Suspended, 6 = Severe Delays
|
||||
private static let majorSeverities: Set<Int> = [1, 2, 3, 6]
|
||||
|
||||
private let config: TFLDataSourceConfig
|
||||
private var cache: (timestamp: Int, data: TFLData)?
|
||||
|
||||
@@ -99,12 +104,10 @@ final class TFLDataSource {
|
||||
guard !seenLines.contains(line.id) else { continue }
|
||||
|
||||
for status in line.lineStatuses {
|
||||
// Skip: 10 = Good Service, 4 = Planned Closure, 5 = Part Closure
|
||||
guard status.statusSeverity < 10 else { continue }
|
||||
guard status.statusSeverity != 4 && status.statusSeverity != 5 else { continue }
|
||||
guard !Self.ignoredSeverities.contains(status.statusSeverity) else { continue }
|
||||
|
||||
seenLines.insert(line.id)
|
||||
let isMajor = status.statusSeverity <= 3 || status.statusSeverity == 6
|
||||
let isMajor = Self.majorSeverities.contains(status.statusSeverity)
|
||||
|
||||
let disruption = Disruption(
|
||||
id: "\(line.id):\(status.statusSeverity)",
|
||||
|
||||
Reference in New Issue
Block a user