Continue post-DatabaseResult simplification.

This commit is contained in:
Brent Simmons committed 2026-06-10 14:55:44 -07:00
1 parent c26cacb88c
commit 31d0b9d3e4
3 files changed
+48 -48

No files matched your search

+23 -23
View File
@@ -815,21 +815,21 @@ public enum FetchType {
public func fetchArticles(_ fetchType: FetchType) throws -> Set<Article> {
switch fetchType {
case .starred(let limit):
return try _fetchStarredArticles(limit: limit)
return _fetchStarredArticles(limit: limit)
case .unread(let limit):
return try _fetchUnreadArticles(limit: limit)
return _fetchUnreadArticles(limit: limit)
case .today(let limit):
return try _fetchTodayArticles(limit: limit)
return _fetchTodayArticles(limit: limit)
case .folder(let folder, let readFilter):
if readFilter {
return try _fetchUnreadArticles(container: folder)
return _fetchUnreadArticles(container: folder)
} else {
return try _fetchArticles(container: folder)
return _fetchArticles(container: folder)
}
case .feed(let feed):
return try _fetchArticles(feed: feed)
return _fetchArticles(feed: feed)
case .articleIDs(let articleIDs):
return try _fetchArticles(articleIDs: articleIDs)
return _fetchArticles(articleIDs: articleIDs)
case .search(let searchString):
return try _fetchArticlesMatching(searchString: searchString)
case .searchWithArticleIDs(let searchString, let articleIDs):
@@ -1203,8 +1203,8 @@ private extension Account {
// MARK: - Starred Articles
func _fetchStarredArticles(limit: Int? = nil) throws -> Set<Article> {
try database.fetchStarredArticles(feedIDs: flattenedFeedsIDs, limit: limit)
func _fetchStarredArticles(limit: Int? = nil) -> Set<Article> {
database.fetchStarredArticles(feedIDs: flattenedFeedsIDs, limit: limit)
}
func _fetchStarredArticlesAsync(limit: Int? = nil) async throws -> Set<Article> {
@@ -1213,8 +1213,8 @@ private extension Account {
// MARK: - Account Unread Articles
func _fetchUnreadArticles(limit: Int? = nil) throws -> Set<Article> {
try _fetchUnreadArticles(container: self, limit: limit)
func _fetchUnreadArticles(limit: Int? = nil) -> Set<Article> {
_fetchUnreadArticles(container: self, limit: limit)
}
func _fetchUnreadArticlesAsync(limit: Int? = nil) async throws -> Set<Article> {
@@ -1223,8 +1223,8 @@ private extension Account {
// MARK: - Today Articles
func _fetchTodayArticles(limit: Int? = nil) throws -> Set<Article> {
try database.fetchTodayArticles(feedIDs: flattenedFeedsIDs, limit: limit)
func _fetchTodayArticles(limit: Int? = nil) -> Set<Article> {
database.fetchTodayArticles(feedIDs: flattenedFeedsIDs, limit: limit)
}
func _fetchTodayArticlesAsync(limit: Int? = nil) async throws -> Set<Article> {
@@ -1233,9 +1233,9 @@ private extension Account {
// MARK: - Container Articles
func _fetchArticles(container: Container) throws -> Set<Article> {
func _fetchArticles(container: Container) -> Set<Article> {
let feeds = container.flattenedFeeds()
let articles = try database.fetchArticles(feedIDs: feeds.feedIDs())
let articles = database.fetchArticles(feedIDs: feeds.feedIDs())
validateUnreadCountsAfterFetchingUnreadArticles(feeds: feeds, articles: articles)
return articles
}
@@ -1247,9 +1247,9 @@ private extension Account {
return articles
}
func _fetchUnreadArticles(container: Container, limit: Int? = nil) throws -> Set<Article> {
func _fetchUnreadArticles(container: Container, limit: Int? = nil) -> Set<Article> {
let feeds = container.flattenedFeeds()
let articles = try database.fetchUnreadArticles(feedIDs: feeds.feedIDs(), limit: limit)
let articles = database.fetchUnreadArticles(feedIDs: feeds.feedIDs(), limit: limit)
// We don't validate limit queries because they, by definition, won't correctly match the
// complete unread state for the given container.
@@ -1275,8 +1275,8 @@ private extension Account {
// MARK: - Feed Articles
func _fetchArticles(feed: Feed) throws -> Set<Article> {
let articles = try database.fetchArticles(feedID: feed.feedID)
func _fetchArticles(feed: Feed) -> Set<Article> {
let articles = database.fetchArticles(feedID: feed.feedID)
validateUnreadCount(feed: feed, articles: articles)
return articles
}
@@ -1287,16 +1287,16 @@ private extension Account {
return articles
}
func _fetchUnreadArticles(feed: Feed) throws -> Set<Article> {
let articles = try database.fetchUnreadArticles(feedIDs: Set([feed.feedID]))
func _fetchUnreadArticles(feed: Feed) -> Set<Article> {
let articles = database.fetchUnreadArticles(feedIDs: Set([feed.feedID]))
validateUnreadCount(feed: feed, articles: articles)
return articles
}
// MARK: - ArticleIDs Articles
func _fetchArticles(articleIDs: Set<String>) throws -> Set<Article> {
try database.fetchArticles(articleIDs: articleIDs)
func _fetchArticles(articleIDs: Set<String>) -> Set<Article> {
database.fetchArticles(articleIDs: articleIDs)
}
func _fetchArticlesAsync(articleIDs: Set<String>) async throws -> Set<Article> {
@@ -108,34 +108,34 @@ public struct ArticleCounts: Sendable {
// MARK: - Fetching Articles
public func fetchArticles(feedID: String) throws -> Set<Article> {
public func fetchArticles(feedID: String) -> Set<Article> {
Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)")
return try articlesTable.fetchArticles(feedID)
return articlesTable.fetchArticles(feedID)
}
public func fetchArticles(feedIDs: Set<String>) throws -> Set<Article> {
public func fetchArticles(feedIDs: Set<String>) -> Set<Article> {
Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)")
return try articlesTable.fetchArticles(feedIDs)
return articlesTable.fetchArticles(feedIDs)
}
public func fetchArticles(articleIDs: Set<String>) throws -> Set<Article> {
public func fetchArticles(articleIDs: Set<String>) -> Set<Article> {
Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)")
return try articlesTable.fetchArticles(articleIDs: articleIDs)
return articlesTable.fetchArticles(articleIDs: articleIDs)
}
public func fetchUnreadArticles(feedIDs: Set<String>, limit: Int? = nil) throws -> Set<Article> {
public func fetchUnreadArticles(feedIDs: Set<String>, limit: Int? = nil) -> Set<Article> {
Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)")
return try articlesTable.fetchUnreadArticles(feedIDs, limit)
return articlesTable.fetchUnreadArticles(feedIDs, limit)
}
public func fetchTodayArticles(feedIDs: Set<String>, limit: Int? = nil) throws -> Set<Article> {
public func fetchTodayArticles(feedIDs: Set<String>, limit: Int? = nil) -> Set<Article> {
Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)")
return try articlesTable.fetchArticlesSince(feedIDs, todayCutoffDate(), limit)
return articlesTable.fetchArticlesSince(feedIDs, todayCutoffDate(), limit)
}
public func fetchStarredArticles(feedIDs: Set<String>, limit: Int? = nil) throws -> Set<Article> {
public func fetchStarredArticles(feedIDs: Set<String>, limit: Int? = nil) -> Set<Article> {
Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)")
return try articlesTable.fetchStarredArticles(feedIDs, limit)
return articlesTable.fetchStarredArticles(feedIDs, limit)
}
public func fetchStarredArticlesCount(feedIDs: Set<String>) throws -> Int {
@@ -48,16 +48,16 @@ final class ArticlesTable: DatabaseTable, Sendable {
// MARK: - Fetching Articles for Feed
func fetchArticles(_ feedID: String) throws -> Set<Article> {
return try fetchArticles { self.fetchArticlesForFeedID(feedID, $0) }
func fetchArticles(_ feedID: String) -> Set<Article> {
fetchArticles { self.fetchArticlesForFeedID(feedID, $0) }
}
func fetchArticlesAsync(_ feedID: String, _ completion: @escaping ArticleSetResultBlock) {
fetchArticlesAsync({ self.fetchArticlesForFeedID(feedID, $0) }, completion)
}
func fetchArticles(_ feedIDs: Set<String>) throws -> Set<Article> {
return try fetchArticles { self.fetchArticles(feedIDs, $0) }
func fetchArticles(_ feedIDs: Set<String>) -> Set<Article> {
fetchArticles { self.fetchArticles(feedIDs, $0) }
}
func fetchArticlesAsync(_ feedIDs: Set<String>, _ completion: @escaping ArticleSetResultBlock) {
@@ -66,8 +66,8 @@ final class ArticlesTable: DatabaseTable, Sendable {
// MARK: - Fetching Articles by articleID
func fetchArticles(articleIDs: Set<String>) throws -> Set<Article> {
return try fetchArticles { self.fetchArticles(articleIDs: articleIDs, $0) }
func fetchArticles(articleIDs: Set<String>) -> Set<Article> {
fetchArticles { self.fetchArticles(articleIDs: articleIDs, $0) }
}
func fetchArticlesAsync(articleIDs: Set<String>, _ completion: @escaping ArticleSetResultBlock) {
@@ -76,8 +76,8 @@ final class ArticlesTable: DatabaseTable, Sendable {
// MARK: - Fetching Unread Articles
func fetchUnreadArticles(_ feedIDs: Set<String>, _ limit: Int?) throws -> Set<Article> {
return try fetchArticles { self.fetchUnreadArticles(feedIDs, limit, $0) }
func fetchUnreadArticles(_ feedIDs: Set<String>, _ limit: Int?) -> Set<Article> {
fetchArticles { self.fetchUnreadArticles(feedIDs, limit, $0) }
}
func fetchUnreadArticlesAsync(_ feedIDs: Set<String>, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) {
@@ -86,8 +86,8 @@ final class ArticlesTable: DatabaseTable, Sendable {
// MARK: - Fetching Today Articles
func fetchArticlesSince(_ feedIDs: Set<String>, _ cutoffDate: Date, _ limit: Int?) throws -> Set<Article> {
return try fetchArticles { self.fetchArticlesSince(feedIDs, cutoffDate, limit, $0) }
func fetchArticlesSince(_ feedIDs: Set<String>, _ cutoffDate: Date, _ limit: Int?) -> Set<Article> {
fetchArticles { self.fetchArticlesSince(feedIDs, cutoffDate, limit, $0) }
}
func fetchArticlesSinceAsync(_ feedIDs: Set<String>, _ cutoffDate: Date, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) {
@@ -96,8 +96,8 @@ final class ArticlesTable: DatabaseTable, Sendable {
// MARK: - Fetching Starred Articles
func fetchStarredArticles(_ feedIDs: Set<String>, _ limit: Int?) throws -> Set<Article> {
return try fetchArticles { self.fetchStarredArticles(feedIDs, limit, $0) }
func fetchStarredArticles(_ feedIDs: Set<String>, _ limit: Int?) -> Set<Article> {
fetchArticles { self.fetchStarredArticles(feedIDs, limit, $0) }
}
func fetchStarredArticlesAsync(_ feedIDs: Set<String>, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) {
@@ -625,7 +625,7 @@ nonisolated private extension ArticlesTable {
// MARK: - Fetching
private func fetchArticles(_ fetchMethod: @escaping ArticlesFetchMethod) throws -> Set<Article> {
private func fetchArticles(_ fetchMethod: @escaping ArticlesFetchMethod) -> Set<Article> {
nonisolated(unsafe) var articles = Set<Article>()
queue.runInDatabaseSync { database in