@@ -267,28 +267,6 @@ final class SyncCoordinator {
267267 collectDirtySSHProfiles ( into: & recordsToSave, deletions: & recordIDsToDelete, zoneID: zoneID)
268268 }
269269
270- // Collect unsynced query history
271- if settings. syncQueryHistory {
272- let limit = settings. historySyncLimit. limit ?? Int . max
273- let unsyncedEntries = await QueryHistoryStorage . shared. unsyncedHistoryEntries ( limit: limit)
274- for entry in unsyncedEntries {
275- recordsToSave. append (
276- SyncRecordMapper . toCKRecord (
277- entryId: entry. id. uuidString,
278- query: entry. query,
279- connectionId: entry. connectionId. uuidString,
280- databaseName: entry. databaseName,
281- executedAt: entry. executedAt,
282- executionTime: entry. executionTime,
283- rowCount: Int64 ( entry. rowCount) ,
284- wasSuccessful: entry. wasSuccessful,
285- errorMessage: entry. errorMessage,
286- in: zoneID
287- )
288- )
289- }
290- }
291-
292270 // Collect dirty settings
293271 if settings. syncSettings {
294272 let dirtySettingsIds = changeTracker. dirtyRecords ( for: . settings)
@@ -320,9 +298,6 @@ final class SyncCoordinator {
320298 if settings. syncSettings {
321299 changeTracker. clearAllDirty ( . settings)
322300 }
323- if settings. syncQueryHistory {
324- changeTracker. clearAllDirty ( . queryHistory)
325- }
326301
327302 // Clear tombstones only for types that were actually pushed
328303 if settings. syncConnections {
@@ -348,19 +323,6 @@ final class SyncCoordinator {
348323 metadataStorage. removeTombstone ( type: . settings, id: tombstone. id)
349324 }
350325 }
351- if settings. syncQueryHistory {
352- for tombstone in metadataStorage. tombstones ( for: . queryHistory) {
353- metadataStorage. removeTombstone ( type: . queryHistory, id: tombstone. id)
354- }
355-
356- // Mark pushed history entries as synced in local storage
357- let syncedIds = recordsToSave
358- . filter { $0. recordType == SyncRecordType . queryHistory. rawValue }
359- . compactMap { $0 [ " entryId " ] as? String }
360- if !syncedIds. isEmpty {
361- await QueryHistoryStorage . shared. markHistoryEntriesSynced ( ids: syncedIds)
362- }
363- }
364326
365327 Self . logger. info ( " Push completed: \( recordsToSave. count) saved, \( recordIDsToDelete. count) deleted " )
366328 } catch let error as CKError where error. code == . serverRecordChanged {
@@ -441,8 +403,6 @@ final class SyncCoordinator {
441403 applyRemoteSSHProfile ( record)
442404 case SyncRecordType . settings. rawValue where settings. syncSettings:
443405 applyRemoteSettings ( record)
444- case SyncRecordType . queryHistory. rawValue where settings. syncQueryHistory:
445- applyRemoteQueryHistory ( record)
446406 default :
447407 break
448408 }
@@ -536,38 +496,6 @@ final class SyncCoordinator {
536496 applySettingsData ( data, for: category)
537497 }
538498
539- private func applyRemoteQueryHistory( _ record: CKRecord ) {
540- guard let entryIdString = record [ " entryId " ] as? String ,
541- let entryId = UUID ( uuidString: entryIdString) ,
542- let query = record [ " query " ] as? String ,
543- let executedAt = record [ " executedAt " ] as? Date
544- else { return }
545-
546- let connectionId = ( record [ " connectionId " ] as? String ) . flatMap { UUID ( uuidString: $0) } ?? UUID ( )
547- let databaseName = record [ " databaseName " ] as? String ?? " "
548- let executionTime = record [ " executionTime " ] as? Double ?? 0
549- let rowCount = ( record [ " rowCount " ] as? Int64 ) . map { Int ( $0) } ?? 0
550- let wasSuccessful = ( record [ " wasSuccessful " ] as? Int64 ?? 1 ) != 0
551- let errorMessage = record [ " errorMessage " ] as? String
552-
553- let entry = QueryHistoryEntry (
554- id: entryId,
555- query: query,
556- connectionId: connectionId,
557- databaseName: databaseName,
558- executedAt: executedAt,
559- executionTime: executionTime,
560- rowCount: rowCount,
561- wasSuccessful: wasSuccessful,
562- errorMessage: errorMessage
563- )
564-
565- Task {
566- _ = await QueryHistoryStorage . shared. addHistory ( entry)
567- await QueryHistoryStorage . shared. markHistoryEntriesSynced ( ids: [ entryIdString] )
568- }
569- }
570-
571499 private func applyRemoteDeletion( _ recordID: CKRecord . ID ) {
572500 let recordName = recordID. recordName
573501
@@ -714,7 +642,6 @@ final class SyncCoordinator {
714642 case SyncRecordType . group. rawValue: syncRecordType = . group
715643 case SyncRecordType . tag. rawValue: syncRecordType = . tag
716644 case SyncRecordType . settings. rawValue: syncRecordType = . settings
717- case SyncRecordType . queryHistory. rawValue: syncRecordType = . queryHistory
718645 case SyncRecordType . sshProfile. rawValue: syncRecordType = . sshProfile
719646 default : continue
720647 }
0 commit comments