Skip to content

Commit

Permalink
Revert to old currentScans calculation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
quanganhdo committed Jan 8, 2025
1 parent e08fac0 commit 0d7d24b
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ struct MapperToUI {
return accumulator + brokerQueryData.totalScans
}

let currentScans = groupedByBroker.reduce(0) { accumulator, brokerQueryData in
return accumulator + brokerQueryData.currentScans
}

let withSortedGroups = groupedByBroker.map { $0.sortedByLastRunDate() }

let sorted = withSortedGroups.sortedByLastRunDate()
Expand All @@ -40,7 +44,7 @@ struct MapperToUI {
brokerQueryGroup.scannedBrokers
}

let scanProgress = DBPUIScanProgress(currentScans: partiallyScannedBrokers.count,
let scanProgress = DBPUIScanProgress(currentScans: currentScans,
totalScans: totalScans,
scannedBrokers: partiallyScannedBrokers)

Expand Down Expand Up @@ -375,6 +379,18 @@ fileprivate extension Array where Element == BrokerProfileQueryData {
return 1 + broker.mirrorSites.filter { $0.shouldWeIncludeMirrorSite() }.count
}

var currentScans: Int {
guard let broker = self.first?.dataBroker else { return 0 }

let didAllQueriesFinished = allSatisfy { $0.scanJobData.lastRunDate != nil }

if !didAllQueriesFinished {
return 0
} else {
return 1 + broker.mirrorSites.filter { $0.shouldWeIncludeMirrorSite() }.count
}
}

/// Returns an array of brokers which have been either fully or partially scanned
///
/// A broker is considered fully scanned is all scan jobs for that broker have completed.
Expand Down

0 comments on commit 0d7d24b

Please sign in to comment.