Files
Morgan Pretty b11d8bc394 Started working on new reupload logic for user display pics
• Started working on the updated logic for the ReuploadUserDisplayPictureJob
• Pulled across a few changes from the refactored networking
• Pulled across the profile_updated changes from the animated profile pictures PR
2025-09-24 15:29:28 +10:00

41 lines
1.5 KiB
Swift

// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
import SessionUtilitiesKit
enum _012_AddJobPriority: Migration {
static let identifier: String = "utilitiesKit.AddJobPriority"
static let minExpectedRunDuration: TimeInterval = 0.1
static let createdTables: [(TableRecord & FetchableRecord).Type] = []
static func migrate(_ db: ObservingDatabase, using dependencies: Dependencies) throws {
// Add `priority` to the job table
try db.alter(table: "job") { t in
t.add(column: "priority", .integer).defaults(to: 0)
}
// Update the priorities for the below job types (want to ensure they run in the order
// specified to avoid weird bugs)
let variantPriorities: [Int: [Job.Variant]] = [
7: [Job.Variant.disappearingMessages],
6: [Job.Variant.failedMessageSends, Job.Variant.failedAttachmentDownloads],
5: [Job.Variant._legacy_getSnodePool],
4: [Job.Variant.syncPushTokens],
3: [Job.Variant.retrieveDefaultOpenGroupRooms],
2: [Job.Variant.reuploadUserDisplayPicture],
1: [Job.Variant.garbageCollection]
]
try variantPriorities.forEach { priority, variants in
try db.execute(sql: """
UPDATE job
SET priority = \(priority)
WHERE variant IN (\(variants.map { "\($0.rawValue)" }.joined(separator: ", ")))
""")
}
MigrationExecution.updateProgress(1)
}
}