Remove all references to fetchArticleIDsForStatusesWithoutArticles. Use fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate instead.
This commit is contained in:
parent
6d499c8848
commit
db564d9cf9
|
@ -689,11 +689,6 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
database.fetchStarredArticleIDsAsync(webFeedIDs: flattenedWebFeeds().webFeedIDs(), completion: completion)
|
||||
}
|
||||
|
||||
/// Deprecated. Use fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate instead.
|
||||
public func fetchArticleIDsForStatusesWithoutArticles() throws -> Set<String> {
|
||||
return try database.fetchArticleIDsForStatusesWithoutArticles()
|
||||
}
|
||||
|
||||
/// Fetch articleIDs for articles that we should have, but don’t. These articles are not userDeleted, and they are either (starred) or (unread and newer than the article cutoff date).
|
||||
public func fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(_ completion: @escaping ArticleIDsCompletionBlock) {
|
||||
database.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(completion)
|
||||
|
|
|
@ -165,36 +165,45 @@ final class FeedWranglerAccountDelegate: AccountDelegate {
|
|||
}
|
||||
|
||||
func refreshMissingArticles(for account: Account, completion: @escaping ((Result<Void, Error>)-> Void)) {
|
||||
guard let fetchedArticleIDs = try? account.fetchArticleIDsForStatusesWithoutArticles() else {
|
||||
return
|
||||
}
|
||||
account.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate { articleIDsResult in
|
||||
|
||||
os_log(.debug, log: log, "Refreshing missing articles...")
|
||||
let group = DispatchGroup()
|
||||
|
||||
let articleIDs = Array(fetchedArticleIDs)
|
||||
let chunkedArticleIDs = articleIDs.chunked(into: 100)
|
||||
|
||||
for chunk in chunkedArticleIDs {
|
||||
group.enter()
|
||||
self.caller.retrieveEntries(articleIDs: chunk) { result in
|
||||
switch result {
|
||||
case .success(let entries):
|
||||
self.syncFeedItems(account, entries) {
|
||||
group.leave()
|
||||
func process(_ fetchedArticleIDs: Set<String>) {
|
||||
os_log(.debug, log: self.log, "Refreshing missing articles...")
|
||||
let group = DispatchGroup()
|
||||
|
||||
let articleIDs = Array(fetchedArticleIDs)
|
||||
let chunkedArticleIDs = articleIDs.chunked(into: 100)
|
||||
|
||||
for chunk in chunkedArticleIDs {
|
||||
group.enter()
|
||||
self.caller.retrieveEntries(articleIDs: chunk) { result in
|
||||
switch result {
|
||||
case .success(let entries):
|
||||
self.syncFeedItems(account, entries) {
|
||||
group.leave()
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Refresh missing articles failed: %@", error.localizedDescription)
|
||||
group.leave()
|
||||
}
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Refresh missing articles failed: %@", error.localizedDescription)
|
||||
group.leave()
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
self.refreshProgress.completeTask()
|
||||
os_log(.debug, log: self.log, "Done refreshing missing articles.")
|
||||
completion(.success(()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
self.refreshProgress.completeTask()
|
||||
os_log(.debug, log: self.log, "Done refreshing missing articles.")
|
||||
completion(.success(()))
|
||||
|
||||
switch articleIDsResult {
|
||||
case .success(let articleIDs):
|
||||
process(articleIDs)
|
||||
case .failure(let databaseError):
|
||||
self.refreshProgress.completeTask()
|
||||
completion(.failure(databaseError))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -837,38 +837,46 @@ private extension ReaderAPIAccountDelegate {
|
|||
}
|
||||
|
||||
func refreshMissingArticles(_ account: Account, completion: @escaping VoidCompletionBlock) {
|
||||
guard let fetchedArticleIDs = try? account.fetchArticleIDsForStatusesWithoutArticles() else {
|
||||
self.refreshProgress.completeTask()
|
||||
return
|
||||
}
|
||||
account.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate { articleIDsResult in
|
||||
|
||||
os_log(.debug, log: log, "Refreshing missing articles...")
|
||||
let group = DispatchGroup()
|
||||
func process(_ fetchedArticleIDs: Set<String>) {
|
||||
os_log(.debug, log: self.log, "Refreshing missing articles...")
|
||||
let group = DispatchGroup()
|
||||
|
||||
let articleIDs = Array(fetchedArticleIDs)
|
||||
let chunkedArticleIDs = articleIDs.chunked(into: 100)
|
||||
let articleIDs = Array(fetchedArticleIDs)
|
||||
let chunkedArticleIDs = articleIDs.chunked(into: 100)
|
||||
|
||||
for chunk in chunkedArticleIDs {
|
||||
group.enter()
|
||||
self.caller.retrieveEntries(articleIDs: chunk) { result in
|
||||
for chunk in chunkedArticleIDs {
|
||||
group.enter()
|
||||
self.caller.retrieveEntries(articleIDs: chunk) { result in
|
||||
|
||||
switch result {
|
||||
case .success(let entries):
|
||||
self.processEntries(account: account, entries: entries) {
|
||||
group.leave()
|
||||
switch result {
|
||||
case .success(let entries):
|
||||
self.processEntries(account: account, entries: entries) {
|
||||
group.leave()
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Refresh missing articles failed: %@.", error.localizedDescription)
|
||||
group.leave()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Refresh missing articles failed: %@.", error.localizedDescription)
|
||||
group.leave()
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
self.refreshProgress.completeTask()
|
||||
os_log(.debug, log: self.log, "Done refreshing missing articles.")
|
||||
completion()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
self.refreshProgress.completeTask()
|
||||
os_log(.debug, log: self.log, "Done refreshing missing articles.")
|
||||
completion()
|
||||
switch articleIDsResult {
|
||||
case .success(let articleIDs):
|
||||
process(articleIDs)
|
||||
case .failure:
|
||||
self.refreshProgress.completeTask()
|
||||
completion()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,11 +176,6 @@ public final class ArticlesDatabase {
|
|||
articlesTable.fetchStarredArticleIDsAsync(webFeedIDs, completion)
|
||||
}
|
||||
|
||||
/// Deprecated. Use `fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate` instead.
|
||||
public func fetchArticleIDsForStatusesWithoutArticles() throws -> Set<String> {
|
||||
return try articlesTable.fetchArticleIDsForStatusesWithoutArticles()
|
||||
}
|
||||
|
||||
/// Fetch articleIDs for articles that we should have, but don’t. These articles are not userDeleted, and they are either (starred) or (unread and newer than the article cutoff date).
|
||||
public func fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(_ completion: @escaping ArticleIDsCompletionBlock) {
|
||||
articlesTable.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(completion)
|
||||
|
|
|
@ -380,10 +380,6 @@ final class ArticlesTable: DatabaseTable {
|
|||
return try statusesTable.fetchStarredArticleIDs()
|
||||
}
|
||||
|
||||
func fetchArticleIDsForStatusesWithoutArticles() throws -> Set<String> {
|
||||
return try statusesTable.fetchArticleIDsForStatusesWithoutArticles()
|
||||
}
|
||||
|
||||
func fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(_ completion: @escaping ArticleIDsCompletionBlock) {
|
||||
statusesTable.fetchArticleIDsForStatusesWithoutArticlesNewerThan(articleCutoffDate, completion)
|
||||
}
|
||||
|
|
|
@ -101,10 +101,6 @@ final class StatusesTable: DatabaseTable {
|
|||
return try fetchArticleIDs("select articleID from statuses where starred=1 and userDeleted=0;")
|
||||
}
|
||||
|
||||
func fetchArticleIDsForStatusesWithoutArticles() throws -> Set<String> {
|
||||
return try fetchArticleIDs("select articleID from statuses s where (read=0 or starred=1) and userDeleted=0 and not exists (select 1 from articles a where a.articleID = s.articleID);")
|
||||
}
|
||||
|
||||
func fetchArticleIDsForStatusesWithoutArticlesNewerThan(_ cutoffDate: Date, _ completion: @escaping ArticleIDsCompletionBlock) {
|
||||
queue.runInDatabase { databaseResult in
|
||||
|
||||
|
|
Loading…
Reference in New Issue