Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update opt out retry interval to every 5 days #3536

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public protocol DataBrokerProtectionRepository {
func fetchOptOutHistoryEvents(brokerId: Int64, profileQueryId: Int64, extractedProfileId: Int64) throws -> [HistoryEvent]
func hasMatches() throws -> Bool

func fetchAllAttempts() throws -> [AttemptInformation]
func fetchAttemptInformation(for extractedProfileId: Int64) throws -> AttemptInformation?
func addAttempt(extractedProfileId: Int64, attemptUUID: UUID, dataBroker: String, lastStageDate: Date, startTime: Date) throws
}
Expand Down Expand Up @@ -487,6 +488,17 @@ final class DataBrokerProtectionDatabase: DataBrokerProtectionRepository {
}
}

func fetchAllAttempts() throws -> [AttemptInformation] {
do {
let vault = try self.vault ?? DataBrokerProtectionSecureVaultFactory.makeVault(reporter: secureVaultErrorReporter)
return try vault.fetchAllAttempts()
} catch {
Logger.dataBrokerProtection.error("Database error: fetchAllAttempts, error: \(error.localizedDescription, privacy: .public)")
pixelHandler.fire(.generalError(error: error, functionOccurredIn: "DataBrokerProtectionDatabase.fetchAllAttempts"))
throw error
}
}

func fetchAttemptInformation(for extractedProfileId: Int64) throws -> AttemptInformation? {
do {
let vault = try self.vault ?? DataBrokerProtectionSecureVaultFactory.makeVault(reporter: secureVaultErrorReporter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ final class DataBrokerDatabaseBrowserViewModel: ObservableObject {
guard let dataManager = self.dataManager else { return }

Task {
guard let data = try? dataManager.fetchBrokerProfileQueryData(ignoresCache: true) else {
guard let data = try? dataManager.fetchBrokerProfileQueryData(ignoresCache: true),
let attempts = try? dataManager.fetchAllOptOutAttempts() else {
assertionFailure("DataManager error during DataBrokerDatavaseBrowserViewModel.updateTables")
return
}
Expand All @@ -68,9 +69,10 @@ final class DataBrokerDatabaseBrowserViewModel: ObservableObject {
let optOutsTable = createTable(using: optOutJobs, tableName: "OptOutOperation")
let extractedProfilesTable = createTable(using: extractedProfiles, tableName: "ExtractedProfile")
let eventsTable = createTable(using: events.sorted(by: { $0.date < $1.date }), tableName: "Events")
let attemptsTable = createTable(using: attempts.sorted(by: <), tableName: "OptOutAttempts")

DispatchQueue.main.async {
self.tables = [brokersTable, profileQueriesTable, scansTable, optOutsTable, extractedProfilesTable, eventsTable]
self.tables = [brokersTable, profileQueriesTable, scansTable, optOutsTable, extractedProfilesTable, eventsTable, attemptsTable]
}
}
}
Expand Down Expand Up @@ -136,3 +138,25 @@ struct DataBrokerDatabaseBrowserData {
}

}

extension DataBrokerProtectionDataManager {
func fetchAllOptOutAttempts() throws -> [AttemptInformation] {
try database.fetchAllAttempts()
}
}

extension AttemptInformation: Comparable {
public static func < (lhs: AttemptInformation, rhs: AttemptInformation) -> Bool {
if lhs.extractedProfileId != rhs.extractedProfileId {
return lhs.extractedProfileId < rhs.extractedProfileId
} else if lhs.dataBroker != rhs.dataBroker {
return lhs.dataBroker < rhs.dataBroker
} else {
return lhs.startDate < rhs.startDate
}
}

public static func == (lhs: AttemptInformation, rhs: AttemptInformation) -> Bool {
lhs.attemptId == rhs.attemptId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ struct DataBrokerProfileQueryOperationManager: OperationsManager {
profileQueryId: profileQueryId)

try database.addAttempt(extractedProfileId: extractedProfileId,
attemptUUID: stageDurationCalculator.attemptId,
dataBroker: stageDurationCalculator.dataBroker,
lastStageDate: stageDurationCalculator.lastStateTime,
startTime: stageDurationCalculator.startTime)
attemptUUID: stageDurationCalculator.attemptId,
dataBroker: stageDurationCalculator.dataBroker,
lastStageDate: stageDurationCalculator.lastStateTime,
startTime: stageDurationCalculator.startTime)
try database.add(.init(extractedProfileId: extractedProfileId, brokerId: brokerId, profileQueryId: profileQueryId, type: .optOutRequested))
try incrementAttemptCountIfNeeded(
database: database,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 0,
"maintenanceScan": 240
"maintenanceScan": 120
},
"addedDatetime": 1725632531153,
"version": "0.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schedulingConfig": {
"retryError": 48,
"confirmOptOutScan": 72,
"maintenanceScan": 240,
"maintenanceScan": 120,
"maxAttempts": -1
}
}
Loading
Loading