Added the catalogue models and seed to support phase 6 of the POC prototype in the Persistence package.
This commit is contained in:
1 parent
31d2d98d49
commit
256d22df40
10 files changed
+473
-4
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import Foundation
|
||||
|
||||
/// A `Sendable` snapshot of a con where shops trade in person, so a sale agreed on the site can be collected there.
|
||||
public struct Event: Sendable, Equatable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The event's URL slug.
|
||||
public let slug: String
|
||||
/// The event's name.
|
||||
public let name: String
|
||||
/// Where it is held, e.g. `Jaarbeurs, Utrecht`.
|
||||
public let venue: String
|
||||
/// The first day.
|
||||
public let startsOn: Date
|
||||
/// The last day.
|
||||
public let endsOn: Date
|
||||
/// The shops trading there.
|
||||
public let shops: [Shop]
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
public init(
|
||||
slug: String,
|
||||
name: String,
|
||||
venue: String,
|
||||
startsOn: Date,
|
||||
endsOn: Date,
|
||||
shops: [Shop] = []
|
||||
) {
|
||||
self.slug = slug
|
||||
self.name = name
|
||||
self.venue = venue
|
||||
self.startsOn = startsOn
|
||||
self.endsOn = endsOn
|
||||
self.shops = shops
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,8 @@ public struct ListingFilter: Sendable, Equatable {
|
||||
public var verifiedShops: Bool
|
||||
/// The slug of the one shop to match, or `nil` for all shops.
|
||||
public var shop: String?
|
||||
/// The slugs of the shops to match — those trading at an event, say — or `nil` for all shops.
|
||||
public var shops: [String]?
|
||||
/// The order of the results.
|
||||
public var sort: Sort
|
||||
|
||||
@@ -51,6 +53,7 @@ public struct ListingFilter: Sendable, Equatable {
|
||||
acceptsOffers: Bool = false,
|
||||
verifiedShops: Bool = false,
|
||||
shop: String? = nil,
|
||||
shops: [String]? = nil,
|
||||
sort: Sort = .newest
|
||||
) {
|
||||
self.query = query
|
||||
@@ -67,6 +70,7 @@ public struct ListingFilter: Sendable, Equatable {
|
||||
self.acceptsOffers = acceptsOffers
|
||||
self.verifiedShops = verifiedShops
|
||||
self.shop = shop
|
||||
self.shops = shops
|
||||
self.sort = sort
|
||||
}
|
||||
|
||||
@@ -117,6 +121,10 @@ extension ListingFilter {
|
||||
return false
|
||||
}
|
||||
|
||||
if let shops, !shops.contains(listing.shop.slug) {
|
||||
return false
|
||||
}
|
||||
|
||||
if !formats.isEmpty, !formats.contains(listing.format) {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user