Merge branch 'master' of https://github.com/brentsimmons/NetNewsWire
This commit is contained in:
commit
73d6d5f5d5
@ -176,10 +176,16 @@ 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).
|
||||
func fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(_ completion: @escaping ArticleIDsCompletionBlock) {
|
||||
articlesTable.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(completion)
|
||||
}
|
||||
|
||||
public func mark(_ articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) throws -> Set<ArticleStatus>? {
|
||||
return try articlesTable.mark(articles, statusKey, flag)
|
||||
}
|
||||
|
@ -383,7 +383,11 @@ final class ArticlesTable: DatabaseTable {
|
||||
func fetchArticleIDsForStatusesWithoutArticles() throws -> Set<String> {
|
||||
return try statusesTable.fetchArticleIDsForStatusesWithoutArticles()
|
||||
}
|
||||
|
||||
|
||||
func fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(_ completion: @escaping ArticleIDsCompletionBlock) {
|
||||
statusesTable.fetchArticleIDsForStatusesWithoutArticlesNewerThan(articleCutoffDate, completion)
|
||||
}
|
||||
|
||||
func mark(_ articles: Set<Article>, _ statusKey: ArticleStatus.Key, _ flag: Bool) throws -> Set<ArticleStatus>? {
|
||||
var statuses: Set<ArticleStatus>?
|
||||
var error: DatabaseError?
|
||||
|
@ -104,6 +104,39 @@ final class StatusesTable: DatabaseTable {
|
||||
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
|
||||
|
||||
var error: DatabaseError?
|
||||
var articleIDs = Set<String>()
|
||||
|
||||
func makeDatabaseCall(_ database: FMDatabase) {
|
||||
let sql = "select articleID from statuses s where ((starred=1) || (read=0 and dateArrived > ?)) and userDeleted=0 and not exists (select 1 from articles a where a.articleID = s.articleID);"
|
||||
if let resultSet = database.executeQuery(sql, withArgumentsIn: [cutoffDate]) {
|
||||
articleIDs = resultSet.mapToSet(self.articleIDWithRow)
|
||||
}
|
||||
}
|
||||
|
||||
switch databaseResult {
|
||||
case .success(let database):
|
||||
makeDatabaseCall(database)
|
||||
case .failure(let databaseError):
|
||||
error = databaseError
|
||||
}
|
||||
|
||||
if let error = error {
|
||||
DispatchQueue.main.async {
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
else {
|
||||
DispatchQueue.main.async {
|
||||
completion(.success(articleIDs))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fetchArticleIDs(_ sql: String) throws -> Set<String> {
|
||||
var error: DatabaseError?
|
||||
|
Loading…
x
Reference in New Issue
Block a user