Skip to content

Commit 9ee55ec

Browse files
committed
Rename CustomCollection.DTO → Details
1 parent f9de722 commit 9ee55ec

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Sources/App/Commands/Reconcile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ func processPackageDenyList(packageList: [URL], denyList: [URL]) -> [URL] {
138138
}
139139

140140

141-
func reconcileCustomCollection(client: Client, database: Database, fullPackageList: [URL], _ dto: CustomCollection.DTO) async throws {
142-
let collection = try await CustomCollection.findOrCreate(on: database, dto)
141+
func reconcileCustomCollection(client: Client, database: Database, fullPackageList: [URL], _ details: CustomCollection.Details) async throws {
142+
let collection = try await CustomCollection.findOrCreate(on: database, details)
143143

144144
// Limit incoming URLs to 50 since this is input outside of our control
145145
@Dependency(\.packageListRepository) var packageListRepository

Sources/App/Core/Dependencies/PackageListRepositoryClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct PackageListRepositoryClient {
2222
var fetchPackageList: @Sendable (_ client: Client) async throws -> [URL]
2323
var fetchPackageDenyList: @Sendable (_ client: Client) async throws -> [URL]
2424
var fetchCustomCollection: @Sendable (_ client: Client, _ url: URL) async throws -> [URL]
25-
var fetchCustomCollections: @Sendable (_ client: Client) async throws -> [CustomCollection.DTO]
25+
var fetchCustomCollections: @Sendable (_ client: Client) async throws -> [CustomCollection.Details]
2626
}
2727

2828

@@ -62,7 +62,7 @@ extension PackageListRepositoryClient: DependencyKey {
6262
try await client
6363
.get(Constants.customCollectionsUri)
6464
.content
65-
.decode([CustomCollection.DTO].self, using: JSONDecoder())
65+
.decode([CustomCollection.Details].self, using: JSONDecoder())
6666
}
6767
)
6868
}

Sources/App/Models/CustomCollection.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,33 @@ final class CustomCollection: @unchecked Sendable, Model, Content {
5454

5555
init() { }
5656

57-
init(id: Id? = nil, createdAt: Date? = nil, updatedAt: Date? = nil, _ dto: DTO) {
57+
init(id: Id? = nil, createdAt: Date? = nil, updatedAt: Date? = nil, _ details: Details) {
5858
self.id = id
5959
self.createdAt = createdAt
6060
self.updatedAt = updatedAt
61-
self.name = dto.name
62-
self.description = dto.description
63-
self.badge = dto.badge
64-
self.url = dto.url
61+
self.name = details.name
62+
self.description = details.description
63+
self.badge = details.badge
64+
self.url = details.url
6565
}
6666
}
6767

6868

6969
extension CustomCollection {
70-
struct DTO: Codable {
70+
struct Details: Codable {
7171
var name: String
7272
var description: String?
7373
var badge: String?
7474
var url: URL
7575
}
7676

77-
static func findOrCreate(on database: Database, _ dto: DTO) async throws -> CustomCollection {
77+
static func findOrCreate(on database: Database, _ details: Details) async throws -> CustomCollection {
7878
if let collection = try await CustomCollection.query(on: database)
79-
.filter(\.$url == dto.url)
79+
.filter(\.$url == details.url)
8080
.first() {
8181
return collection
8282
} else {
83-
let collection = CustomCollection(dto)
83+
let collection = CustomCollection(details)
8484
try await collection.save(on: database)
8585
return collection
8686
}

0 commit comments

Comments
 (0)