Skip to content

Commit 8e1231c

Browse files
leogdionclaude
andcommitted
fix: include computed totals in JSON output
Added custom encode(to:) method to DetailedSyncResult to explicitly encode the computed properties (totalCreated, totalUpdated, totalFailed) in JSON output. Previously, these computed properties were not included in the JSON because Swift's Codable only encodes stored properties by default. The workflow needs these values to generate the sync summary. **Testing:** - Verified encode() includes all six fields in JSON output - Workflow can now parse totalCreated, totalUpdated, totalFailed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent b785b19 commit 8e1231c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Sources/BushelCloudKit/CloudKit/SyncEngine.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,26 @@ public struct SyncEngine: Sendable {
103103
self.swiftVersions = swiftVersions
104104
}
105105

106+
/// Custom encoding to include computed properties
107+
public func encode(to encoder: Encoder) throws {
108+
var container = encoder.container(keyedBy: CodingKeys.self)
109+
try container.encode(restoreImages, forKey: .restoreImages)
110+
try container.encode(xcodeVersions, forKey: .xcodeVersions)
111+
try container.encode(swiftVersions, forKey: .swiftVersions)
112+
try container.encode(totalCreated, forKey: .totalCreated)
113+
try container.encode(totalUpdated, forKey: .totalUpdated)
114+
try container.encode(totalFailed, forKey: .totalFailed)
115+
}
116+
117+
private enum CodingKeys: String, CodingKey {
118+
case restoreImages
119+
case xcodeVersions
120+
case swiftVersions
121+
case totalCreated
122+
case totalUpdated
123+
case totalFailed
124+
}
125+
106126
/// Convert to JSON string
107127
public func toJSON(pretty: Bool = false) throws -> String {
108128
let encoder = JSONEncoder()

0 commit comments

Comments
 (0)