← All repositories

crossmate

A collaborative crossword app for iPhone and iPad

git clone https://code.inqk.net/crossmate.git


commit c264d3629c39a1849cee361830a9dd75ce97f562
parent 319a83e4193321e598fba3f6f3323ef209d93f81
Author: Michael Camilleri <[email protected]>
Date:   Sun, 26 Apr 2026 11:29:35 +0900

Use shorter identifiers

Diffstat

MCrossmate/Models/CrossmateModel.xcdatamodeld/CrossmateModel.xcdatamodel/contents | 2+-
MCrossmate/Persistence/GameStore.swift | 14+++++++-------
MCrossmate/Services/AppServices.swift | 2+-
MTests/Unit/GameStoreSnapshotPruningTests.swift | 10+++++-----

4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/Crossmate/Models/CrossmateModel.xcdatamodeld/CrossmateModel.xcdatamodel/contents b/Crossmate/Models/CrossmateModel.xcdatamodeld/CrossmateModel.xcdatamodel/contents

@@ -55,7 +55,7 @@
         <attribute name="ckSystemFields" optional="YES" attributeType="Binary"/>
         <attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
         <attribute name="gridState" attributeType="Binary"/>
-        <attribute name="needsMovePruning" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
+        <attribute name="needsPruning" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
         <attribute name="upToLamport" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
         <relationship name="game" maxCount="1" deletionRule="Nullify" destinationEntity="GameEntity" inverseName="snapshots" inverseEntity="GameEntity"/>
         <fetchIndex name="byGameAndLamport">

diff --git a/Crossmate/Persistence/GameStore.swift b/Crossmate/Persistence/GameStore.swift

@@ -188,7 +188,7 @@ final class GameStore {
         for gameIDs: Set<UUID>
     ) -> (snapshotNames: [String], prunedMoveNames: [String]) {
         var snapshotNames: [String] = []
-        var prunedMoveNames = pruneMovesCoveredByDurableSnapshots()
+        let prunedMoveNames = pruneMoves()
 
         for gameID in gameIDs {
             let req = NSFetchRequest<GameEntity>(entityName: "GameEntity")
@@ -238,7 +238,7 @@ final class GameStore {
             let ckName = RecordSerializer.recordName(forSnapshotInGame: gameID, upToLamport: highWater)
             snapshotEntity.ckRecordName = ckName
             snapshotEntity.gridState = try? MoveLog.encodeGridState(grid)
-            snapshotEntity.needsMovePruning = true
+            snapshotEntity.needsPruning = true
 
             if context.hasChanges {
                 try? context.save()
@@ -253,19 +253,19 @@ final class GameStore {
     /// is used directly from CKSyncEngine's saved-record callback; omitting
     /// names performs crash recovery by looking for saved snapshots with
     /// written-back system fields.
-    func pruneMovesCoveredByDurableSnapshots(
+    func pruneMoves(
         ckRecordNames: Set<String>? = nil
     ) -> [String] {
         let req = NSFetchRequest<SnapshotEntity>(entityName: "SnapshotEntity")
         if let ckRecordNames {
             guard !ckRecordNames.isEmpty else { return [] }
             req.predicate = NSPredicate(
-                format: "needsMovePruning == YES AND ckRecordName IN %@",
+                format: "needsPruning == YES AND ckRecordName IN %@",
                 Array(ckRecordNames)
             )
         } else {
             req.predicate = NSPredicate(
-                format: "needsMovePruning == YES AND ckSystemFields != nil"
+                format: "needsPruning == YES AND ckSystemFields != nil"
             )
         }
 
@@ -273,7 +273,7 @@ final class GameStore {
         var prunedMoveNames: [String] = []
         for snapshot in snapshots {
             guard let game = snapshot.game else {
-                snapshot.needsMovePruning = false
+                snapshot.needsPruning = false
                 continue
             }
 
@@ -285,7 +285,7 @@ final class GameStore {
                 }
                 context.delete(move)
             }
-            snapshot.needsMovePruning = false
+            snapshot.needsPruning = false
         }
 
         if context.hasChanges {

diff --git a/Crossmate/Services/AppServices.swift b/Crossmate/Services/AppServices.swift

@@ -101,7 +101,7 @@ final class AppServices {
         }
 
         await syncEngine.setOnSnapshotsSaved { [store, syncEngine] names in
-            let prunedMoveNames = store.pruneMovesCoveredByDurableSnapshots(
+            let prunedMoveNames = store.pruneMoves(
                 ckRecordNames: Set(names)
             )
             await syncEngine.enqueueDeleteRecords(prunedMoveNames)

diff --git a/Tests/Unit/GameStoreSnapshotPruningTests.swift b/Tests/Unit/GameStoreSnapshotPruningTests.swift

@@ -24,7 +24,7 @@ struct GameStoreSnapshotPruningTests {
         let (store, gameID) = try makeStoreWithCompletedGame(moveCount: 2)
         let result = store.createSnapshotsIfNeeded(for: [gameID])
 
-        let pruned = store.pruneMovesCoveredByDurableSnapshots(
+        let pruned = store.pruneMoves(
             ckRecordNames: Set(result.snapshotNames)
         )
 
@@ -42,7 +42,7 @@ struct GameStoreSnapshotPruningTests {
         let result = store.createSnapshotsIfNeeded(for: [gameID])
         try markSnapshotSaved(store: store, ckRecordName: result.snapshotNames[0])
 
-        let pruned = store.pruneMovesCoveredByDurableSnapshots()
+        let pruned = store.pruneMoves()
 
         #expect(pruned == [
             RecordSerializer.recordName(forMoveInGame: gameID, lamport: 1)
@@ -63,10 +63,10 @@ struct GameStoreSnapshotPruningTests {
         snapshot.createdAt = Date()
         snapshot.gridState = try MoveLog.encodeGridState([:])
         snapshot.upToLamport = 1
-        snapshot.needsMovePruning = false
+        snapshot.needsPruning = false
         try context.save()
 
-        let pruned = store.pruneMovesCoveredByDurableSnapshots()
+        let pruned = store.pruneMoves()
 
         #expect(pruned.isEmpty)
         #expect(fetchMoveNames(store: store, gameID: gameID).count == 1)
@@ -126,7 +126,7 @@ struct GameStoreSnapshotPruningTests {
 
     private func fetchPendingPruneSnapshotNames(store: GameStore) -> [String] {
         let request = NSFetchRequest<SnapshotEntity>(entityName: "SnapshotEntity")
-        request.predicate = NSPredicate(format: "needsMovePruning == YES")
+        request.predicate = NSPredicate(format: "needsPruning == YES")
         return ((try? store.persistence.viewContext.fetch(request)) ?? [])
             .compactMap(\.ckRecordName)
             .sorted()