From ac3c8256bc968bd939099e9171bc06624db492fc Mon Sep 17 00:00:00 2001 From: Julian Dunskus Date: Sun, 23 Jun 2024 22:13:25 +0200 Subject: [PATCH] fix whitespace --- .../Back End/Concrete Requests/Sync.swift | 46 +++++++++---------- .../Back End/Objects/ConstructionSite.swift | 10 ++-- .../Back End/Storage/Repository.swift | 8 ++-- .../Issue Manager.xcodeproj/project.pbxproj | 1 + 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/Issue Manager/Back End/Concrete Requests/Sync.swift b/Issue Manager/Back End/Concrete Requests/Sync.swift index d29e23b..5f38ef6 100644 --- a/Issue Manager/Back End/Concrete Requests/Sync.swift +++ b/Issue Manager/Back End/Concrete Requests/Sync.swift @@ -326,25 +326,25 @@ extension SyncContext { } private func pullChangedIssues(for site: ConstructionSite) async throws { - let knownMaps = repository.ids(for: site.allMaps) - let knownCraftsmen = repository.ids(for: site.allCraftsmen) - let knownManagers = repository.ids(for: ConstructionManager.all()) - - func validate(_ issue: Issue) throws { - func check(_ id: Object.ID?, against known: Set) throws { - guard let id else { return } - guard known.contains(id) else { - throw MissingIssueDependency(id: id, knownIDs: known, issue: issue) - } - } - try check(issue.mapID, against: knownMaps) - try check(issue.craftsmanID, against: knownCraftsmen) - try check(issue.status.createdBy, against: knownManagers) - try check(issue.status.registeredBy, against: knownManagers) - try check(issue.status.resolvedBy, against: knownCraftsmen) - try check(issue.status.closedBy, against: knownManagers) - } - + let knownMaps = repository.ids(for: site.allMaps) + let knownCraftsmen = repository.ids(for: site.allCraftsmen) + let knownManagers = repository.ids(for: ConstructionManager.all()) + + func validate(_ issue: Issue) throws { + func check(_ id: Object.ID?, against known: Set) throws { + guard let id else { return } + guard known.contains(id) else { + throw MissingIssueDependency(id: id, knownIDs: known, issue: issue) + } + } + try check(issue.mapID, against: knownMaps) + try check(issue.craftsmanID, against: knownCraftsmen) + try check(issue.status.createdBy, against: knownManagers) + try check(issue.status.registeredBy, against: knownManagers) + try check(issue.status.resolvedBy, against: knownCraftsmen) + try check(issue.status.closedBy, against: knownManagers) + } + var itemsPerPage = 1000 var lastChangeTime = Date.distantPast while true { @@ -364,7 +364,7 @@ extension SyncContext { )) let issues = collection.makeObjects(context: site.id) - try issues.forEach(validate) // validate that foreign key constraints will hold before inserting into DB with a `try!` + try issues.forEach(validate) // validate that foreign key constraints will hold before inserting into DB with a `try!` repository.update(changing: issues) guard collection.view.nextPage != nil else { break } // done @@ -373,9 +373,9 @@ extension SyncContext { } struct MissingIssueDependency: Error { - var id: Object.ID - var knownIDs: Set - var issue: Issue + var id: Object.ID + var knownIDs: Set + var issue: Issue } enum SyncError: Error { diff --git a/Issue Manager/Back End/Objects/ConstructionSite.swift b/Issue Manager/Back End/Objects/ConstructionSite.swift index af302db..642f480 100644 --- a/Issue Manager/Back End/Objects/ConstructionSite.swift +++ b/Issue Manager/Back End/Objects/ConstructionSite.swift @@ -19,17 +19,17 @@ extension ConstructionSite: Identifiable { extension ConstructionSite: DBRecord { static let craftsmen = hasMany(Craftsman.self) var craftsmen: Craftsman.Query { - allCraftsmen.withoutDeleted + allCraftsmen.withoutDeleted } - /// includes deleted craftsmen - var allCraftsmen: Craftsman.Query { request(for: Self.craftsmen) } + /// includes deleted craftsmen + var allCraftsmen: Craftsman.Query { request(for: Self.craftsmen) } static let maps = hasMany(Map.self) var maps: Map.Query { allMaps.withoutDeleted } - /// includes deleted maps - var allMaps: Map.Query { request(for: Self.maps) } + /// includes deleted maps + var allMaps: Map.Query { request(for: Self.maps) } static let issues = hasMany(Issue.self) var issues: Issue.Query { diff --git a/Issue Manager/Back End/Storage/Repository.swift b/Issue Manager/Back End/Storage/Repository.swift index f3cea6b..414d4be 100644 --- a/Issue Manager/Back End/Storage/Repository.swift +++ b/Issue Manager/Back End/Storage/Repository.swift @@ -40,10 +40,10 @@ final class Repository: Sendable { func object(_ id: Object.ID) -> Object? where Object: StoredObject { read(id.get) } - - func ids(for objects: QueryInterfaceRequest) -> Set> where Object: StoredObject { - Set(read(objects.select(ObjectMeta.Columns.id).fetchAll)) - } + + func ids(for objects: QueryInterfaceRequest) -> Set> where Object: StoredObject { + Set(read(objects.select(ObjectMeta.Columns.id).fetchAll)) + } /// saves modifications to an issue func save(_ issue: Issue) { diff --git a/Issue Manager/Issue Manager.xcodeproj/project.pbxproj b/Issue Manager/Issue Manager.xcodeproj/project.pbxproj index 10dae9b..a92f21a 100644 --- a/Issue Manager/Issue Manager.xcodeproj/project.pbxproj +++ b/Issue Manager/Issue Manager.xcodeproj/project.pbxproj @@ -442,6 +442,7 @@ 95F4DAFE214AA2B3005C7D6D /* Frameworks */, ); sourceTree = ""; + usesTabs = 1; }; 9583C2BC20DC748800452695 /* Products */ = { isa = PBXGroup;