Refactor data sources and feed model
This commit is contained in:
@@ -2,60 +2,7 @@
|
||||
// Candidate.swift
|
||||
// iris
|
||||
//
|
||||
// Created by Codex.
|
||||
// Deprecated: data sources now return typed data and the orchestrator produces `FeedItem`s.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import WeatherKit
|
||||
|
||||
struct Candidate: Codable, Equatable {
|
||||
let id: String
|
||||
let type: WinnerType
|
||||
let title: String
|
||||
let subtitle: String
|
||||
let confidence: Double
|
||||
let createdAt: Int
|
||||
let ttlSec: Int
|
||||
let condition: WeatherKit.WeatherCondition?
|
||||
let metadata: [String: String]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case type
|
||||
case title
|
||||
case subtitle
|
||||
case confidence
|
||||
case createdAt
|
||||
case ttlSec
|
||||
case condition
|
||||
case metadata
|
||||
}
|
||||
|
||||
init(id: String,
|
||||
type: WinnerType,
|
||||
title: String,
|
||||
subtitle: String,
|
||||
confidence: Double,
|
||||
createdAt: Int,
|
||||
ttlSec: Int,
|
||||
condition: WeatherKit.WeatherCondition? = nil,
|
||||
metadata: [String: String]? = nil) {
|
||||
self.id = id
|
||||
self.type = type
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
self.confidence = confidence
|
||||
self.createdAt = createdAt
|
||||
self.ttlSec = ttlSec
|
||||
self.condition = condition
|
||||
self.metadata = metadata
|
||||
}
|
||||
|
||||
func isExpired(at now: Int) -> Bool {
|
||||
if ttlSec > 0 {
|
||||
createdAt + ttlSec <= now
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user