Added the catalogue models and seed to support phase 3 of the POC prototype in the Persistence package.

This commit is contained in:
javier committed 2026-09-21 12:11:01 +02:00
1 parent 43dcc03da6
commit b1ceed7790
20 files changed
+2035 -8

No files matched your search

@@ -51,6 +51,8 @@ public struct Listing: Sendable, Equatable {
public let cover: Cover
/// When the copy was listed.
public let listedAt: Date
/// When a sale of the copy was agreed, or `nil` while it is for sale.
public let soldAt: Date?
// MARK: Initializers
@@ -77,7 +79,8 @@ public struct Listing: Sendable, Equatable {
shippingCents: Int,
acceptsOffers: Bool,
cover: Cover,
listedAt: Date
listedAt: Date,
soldAt: Date? = nil
) {
self.slug = slug
self.shop = shop
@@ -102,6 +105,7 @@ public struct Listing: Sendable, Equatable {
self.acceptsOffers = acceptsOffers
self.cover = cover
self.listedAt = listedAt
self.soldAt = soldAt
}
}
@@ -112,6 +116,20 @@ public extension Listing {
// MARK: Computed
/// The grade or condition in a few words: `CGC 9.8` for a slab, `Raw · NM` for a raw issue, the condition alone for a collected edition.
var gradeLabel: String {
if let grader, let grade {
return "\(grader) \(String(format: "%.1f", grade))"
}
return format == "single-issues" ? "Raw · \(condition)" : condition
}
/// Whether the copy is still for sale.
var isAvailable: Bool {
soldAt == nil
}
/// Whether the issue is a key.
var isKey: Bool {
keyNotes != nil