Remove all references to fetchArticleIDsForStatusesWithoutArticles. Use fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate instead.

This commit is contained in:
Brent Simmons 2019-12-17 21:15:20 -08:00
parent 6d499c8848
commit db564d9cf9
6 changed files with 66 additions and 67 deletions

View File

@ -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 dont. 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)

View File

@ -165,11 +165,10 @@ 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...")
func process(_ fetchedArticleIDs: Set<String>) {
os_log(.debug, log: self.log, "Refreshing missing articles...")
let group = DispatchGroup()
let articleIDs = Array(fetchedArticleIDs)
@ -198,6 +197,16 @@ final class FeedWranglerAccountDelegate: AccountDelegate {
}
}
switch articleIDsResult {
case .success(let articleIDs):
process(articleIDs)
case .failure(let databaseError):
self.refreshProgress.completeTask()
completion(.failure(databaseError))
}
}
}
func sendArticleStatus(for account: Account, completion: @escaping VoidResultCompletionBlock) {
os_log(.debug, log: log, "Sending article status...")

View File

@ -837,12 +837,10 @@ 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...")
func process(_ fetchedArticleIDs: Set<String>) {
os_log(.debug, log: self.log, "Refreshing missing articles...")
let group = DispatchGroup()
let articleIDs = Array(fetchedArticleIDs)
@ -872,6 +870,16 @@ private extension ReaderAPIAccountDelegate {
}
}
switch articleIDsResult {
case .success(let articleIDs):
process(articleIDs)
case .failure:
self.refreshProgress.completeTask()
completion()
}
}
}
func refreshArticles(_ account: Account, page: String?, completion: @escaping (() -> Void)) {
guard let page = page else {

View File

@ -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 dont. 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)

View File

@ -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)
}

View File

@ -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