Skip to content

Commit

Permalink
fix whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Dunskus committed Jun 23, 2024
1 parent 9bceaa2 commit ac3c825
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 32 deletions.
46 changes: 23 additions & 23 deletions Issue Manager/Back End/Concrete Requests/Sync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object: StoredObject>(_ id: Object.ID?, against known: Set<Object.ID>) 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<Object: StoredObject>(_ id: Object.ID?, against known: Set<Object.ID>) 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 {
Expand All @@ -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
Expand All @@ -373,9 +373,9 @@ extension SyncContext {
}

struct MissingIssueDependency<Object: StoredObject>: Error {
var id: Object.ID
var knownIDs: Set<Object.ID>
var issue: Issue
var id: Object.ID
var knownIDs: Set<Object.ID>
var issue: Issue
}

enum SyncError: Error {
Expand Down
10 changes: 5 additions & 5 deletions Issue Manager/Back End/Objects/ConstructionSite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions Issue Manager/Back End/Storage/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ final class Repository: Sendable {
func object<Object>(_ id: Object.ID) -> Object? where Object: StoredObject {
read(id.get)
}
func ids<Object>(for objects: QueryInterfaceRequest<Object>) -> Set<ObjectID<Object>> where Object: StoredObject {
Set(read(objects.select(ObjectMeta<Object>.Columns.id).fetchAll))
}
func ids<Object>(for objects: QueryInterfaceRequest<Object>) -> Set<ObjectID<Object>> where Object: StoredObject {
Set(read(objects.select(ObjectMeta<Object>.Columns.id).fetchAll))
}

/// saves modifications to an issue
func save(_ issue: Issue) {
Expand Down
1 change: 1 addition & 0 deletions Issue Manager/Issue Manager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@
95F4DAFE214AA2B3005C7D6D /* Frameworks */,
);
sourceTree = "<group>";
usesTabs = 1;
};
9583C2BC20DC748800452695 /* Products */ = {
isa = PBXGroup;
Expand Down

0 comments on commit ac3c825

Please sign in to comment.