Skip to content

Commit

Permalink
[PAL-694] issue report includes 100 most recent alerts (#690)
Browse files Browse the repository at this point in the history
* issue report includes 100 most recent alerts

* added default value to keep unit tests the same
  • Loading branch information
nhamming authored Jul 30, 2024
1 parent ebe4d78 commit d7149e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Loop/Managers/Alerts/AlertManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ extension AlertManager {
await withCheckedContinuation { continuation in
let startDate = Date() - .days(3.5) // Report the last 3 and half days of alerts
let header = "## Alerts\n"
alertStore.executeQuery(since: startDate, limit: 100) { result in
alertStore.executeQuery(since: startDate, limit: 100, ascending: false) { result in
switch result {
case .failure:
continuation.resume(returning: header)
Expand Down
8 changes: 4 additions & 4 deletions Loop/Managers/Alerts/AlertStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,15 @@ extension AlertStore {
case failure(Error)
}

func executeQuery(fromQueryAnchor queryAnchor: QueryAnchor? = nil, since date: Date, excludingFutureAlerts: Bool = true, now: Date = Date(), limit: Int, completion: @escaping (AlertQueryResult) -> Void) {
func executeQuery(fromQueryAnchor queryAnchor: QueryAnchor? = nil, since date: Date, excludingFutureAlerts: Bool = true, now: Date = Date(), limit: Int, ascending: Bool = true, completion: @escaping (AlertQueryResult) -> Void) {
let sinceDateFilter = SinceDateFilter(predicateExpressionNotYetExpired: predicateExpressionNotYetExpired,
date: date,
excludingFutureAlerts: excludingFutureAlerts,
now: now)
executeAlertQuery(fromQueryAnchor: queryAnchor, queryFilter: sinceDateFilter, limit: limit, completion: completion)
executeAlertQuery(fromQueryAnchor: queryAnchor, queryFilter: sinceDateFilter, limit: limit, ascending: ascending, completion: completion)
}

func executeAlertQuery(fromQueryAnchor queryAnchor: QueryAnchor?, queryFilter: QueryFilter? = nil, limit: Int, completion: @escaping (AlertQueryResult) -> Void) {
func executeAlertQuery(fromQueryAnchor queryAnchor: QueryAnchor?, queryFilter: QueryFilter? = nil, limit: Int, ascending: Bool = true, completion: @escaping (AlertQueryResult) -> Void) {
var queryAnchor = queryAnchor ?? QueryAnchor()
var queryResult = [SyncAlertObject]()
var queryError: Error?
Expand All @@ -449,7 +449,7 @@ extension AlertStore {
} else {
storedRequest.predicate = queryAnchorPredicate
}
storedRequest.sortDescriptors = [NSSortDescriptor(key: "modificationCounter", ascending: true)]
storedRequest.sortDescriptors = [NSSortDescriptor(key: "modificationCounter", ascending: ascending)]
storedRequest.fetchLimit = limit

do {
Expand Down

0 comments on commit d7149e1

Please sign in to comment.