Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
History Fetch updated method name and added a documentation comment …
Browse files Browse the repository at this point in the history
…that it fetches last month only
  • Loading branch information
soner-yuksel committed Jul 27, 2021
1 parent 859375b commit d643b01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Client/Frontend/Sync/BraveCore/BraveCoreMigrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ extension BraveCoreMigrator {
DataController.performOnMainContext { context in
var didSucceed = true

for history in History.fetchAllHistory(context) {
for history in History.fetchMigrationHistory(context) {
if self.migrateChromiumHistory(context: context, history: history) {
history.delete()
} else {
Expand Down
10 changes: 8 additions & 2 deletions Data/models/History.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ public final class History: NSManagedObject, WebsitePresentable, CRUD {
return all(where: predicate, fetchLimit: 100, context: DataController.viewContext) ?? []
}

public class func fetchAllHistory(_ context: NSManagedObjectContext? = nil, visitedAscending: Bool = false) -> [History] {
/// Fetching the History items for migration
/// The last month's data is being displayed to user
/// so data in this period data fetched from old history for migration
/// - Parameters:
/// - context: Managed Object Context
/// - Returns: Return old history items from core data
public class func fetchMigrationHistory(_ context: NSManagedObjectContext? = nil) -> [History] {
let predicate = NSPredicate(format: "visitedOn >= %@", History.thisMonth as CVarArg)
let sortDescriptors = [NSSortDescriptor(key: "visitedOn", ascending: visitedAscending)]
let sortDescriptors = [NSSortDescriptor(key: "visitedOn", ascending: false)]

return all(where: predicate, sortDescriptors: sortDescriptors, context: context ?? DataController.viewContext) ?? []
}
Expand Down

0 comments on commit d643b01

Please sign in to comment.