2024-12-12 11:24:35 +00:00
|
|
|
/// The weekly item data for the list of weeklies.
|
2024-12-22 16:24:48 +00:00
|
|
|
public struct Weekly: Hashable, Identifiable, Sendable {
|
2024-12-12 11:24:35 +00:00
|
|
|
/// The number of the week. The first week starts with 1.
|
|
|
|
public let week: Int
|
|
|
|
|
|
|
|
/// The weekly subject/topic.
|
|
|
|
public let topic: String
|
|
|
|
|
|
|
|
/// The US formatted date the weekly.
|
|
|
|
public let formattedDate: String
|
|
|
|
|
|
|
|
/// How many rants have beeon posted for this weekly.
|
|
|
|
public let numberOfRants: Int
|
|
|
|
|
|
|
|
public var id: Int { week }
|
|
|
|
|
|
|
|
public init(week: Int, topic: String, formattedDate: String, numberOfRants: Int) {
|
|
|
|
self.week = week
|
|
|
|
self.topic = topic
|
|
|
|
self.formattedDate = formattedDate
|
|
|
|
self.numberOfRants = numberOfRants
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Weekly {
|
|
|
|
struct CodingData: Codable {
|
|
|
|
let week: Int
|
|
|
|
let prompt: String
|
|
|
|
let date: String
|
|
|
|
let num_rants: Int
|
|
|
|
|
|
|
|
struct List: Codable {
|
|
|
|
let weeks: [CodingData]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Weekly.CodingData {
|
|
|
|
var decoded: Weekly {
|
|
|
|
.init(
|
|
|
|
week: week,
|
|
|
|
topic: prompt,
|
|
|
|
formattedDate: date,
|
|
|
|
numberOfRants: num_rants
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|