From eb5bfd6ca5cbf80d70cdd57dd8680d98b8a01ce2 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 1 Jun 2026 08:39:09 -0700 Subject: [PATCH] Add Dinosaurs window. --- Mac/AppDelegate.swift | 8 + Mac/Base.lproj/Main.storyboard | 6 + Mac/Dinosaurs/DinosaurRow.swift | 20 ++ Mac/Dinosaurs/DinosaurWindowController.swift | 32 +++ Mac/Dinosaurs/DinosaursFeedProvider.swift | 64 +++++ Mac/Dinosaurs/DinosaursView.swift | 221 ++++++++++++++++++ Mac/MainWindow/MainWindowController.swift | 4 + Modules/Account/Sources/Account/Account.swift | 5 + .../Sources/Account/DataExtensions.swift | 1 + Modules/Account/Sources/Account/Feed.swift | 11 + .../Sources/Account/FeedSettings.swift | 11 + .../Account/FeedSettingsDatabase.swift | 28 ++- .../LocalAccount/LocalAccountRefresher.swift | 2 + .../ArticlesDatabase/ArticlesDatabase.swift | 10 + .../ArticlesDatabase/ArticlesTable.swift | 38 +++ 15 files changed, 459 insertions(+), 2 deletions(-) create mode 100644 Mac/Dinosaurs/DinosaurRow.swift create mode 100644 Mac/Dinosaurs/DinosaurWindowController.swift create mode 100644 Mac/Dinosaurs/DinosaursFeedProvider.swift create mode 100644 Mac/Dinosaurs/DinosaursView.swift diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index a9667c058..b6feccbe0 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -94,6 +94,7 @@ let appName = "NetNewsWire" private var activityWindowController: ActivityWindowController? private var activityLogWindowController: ActivityLogWindowController? private var errorLogWindowController: ErrorLogWindowController? + private var dinosaurWindowController: DinosaurWindowController? private var crashReportWindowController: CrashReportWindowController? // For testing only private var cloudKitStatsWindowController: CloudKitStatsWindowController? private var accountStatsWindowController: AccountStatsWindowController? @@ -582,6 +583,13 @@ let appName = "NetNewsWire" errorLogWindowController!.showWindow(self) } + @IBAction func showDinosaursWindow(_ sender: Any?) { + if dinosaurWindowController == nil { + dinosaurWindowController = DinosaurWindowController() + } + dinosaurWindowController!.showWindow(self) + } + @IBAction func showActivityWindow(_ sender: Any?) { if activityWindowController == nil { activityWindowController = ActivityWindowController() diff --git a/Mac/Base.lproj/Main.storyboard b/Mac/Base.lproj/Main.storyboard index f4fed3515..03bc85340 100644 --- a/Mac/Base.lproj/Main.storyboard +++ b/Mac/Base.lproj/Main.storyboard @@ -600,6 +600,12 @@ + + + + + + diff --git a/Mac/Dinosaurs/DinosaurRow.swift b/Mac/Dinosaurs/DinosaurRow.swift new file mode 100644 index 000000000..7bf85ae0c --- /dev/null +++ b/Mac/Dinosaurs/DinosaurRow.swift @@ -0,0 +1,20 @@ +// +// DinosaurRow.swift +// NetNewsWire +// +// Created by Brent Simmons on 5/31/26. +// + +import Account + +struct DinosaurRow: Identifiable { + + let id: String + let feed: Feed + let account: Account + let accountName: String + let feedName: String + let feedURL: String + let lastArticleDate: Date? + let lastResponseCode: Int? +} diff --git a/Mac/Dinosaurs/DinosaurWindowController.swift b/Mac/Dinosaurs/DinosaurWindowController.swift new file mode 100644 index 000000000..dacbfc7d7 --- /dev/null +++ b/Mac/Dinosaurs/DinosaurWindowController.swift @@ -0,0 +1,32 @@ +// +// DinosaurWindowController.swift +// NetNewsWire +// +// Created by Brent Simmons on 5/31/26. +// + +@preconcurrency import AppKit +import SwiftUI + +final class DinosaurWindowController: NSWindowController { + + init() { + let window = NSWindow( + contentRect: NSRect(x: 0, y: 0, width: 800, height: 500), + styleMask: [.titled, .closable, .miniaturizable, .resizable], + backing: .buffered, + defer: true + ) + window.title = NSLocalizedString("Dinosaurs", comment: "Dinosaurs window title") + window.contentMinSize = NSSize(width: 500, height: 300) + window.contentViewController = NSHostingController(rootView: DinosaursView()) + window.center() + + super.init(window: window) + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) is not supported") + } +} diff --git a/Mac/Dinosaurs/DinosaursFeedProvider.swift b/Mac/Dinosaurs/DinosaursFeedProvider.swift new file mode 100644 index 000000000..caf4d825b --- /dev/null +++ b/Mac/Dinosaurs/DinosaursFeedProvider.swift @@ -0,0 +1,64 @@ +// +// DinosaursFeedProvider.swift +// NetNewsWire +// +// Created by Brent Simmons on 5/31/26. +// + +import Foundation +import Account + +@MainActor struct DinosaursFeedProvider { + + let rows: [DinosaurRow] + let showAccountColumn: Bool + + static func fetch(monthThreshold: Int) async -> DinosaursFeedProvider { + let directReadingAccounts = AccountManager.shared.activeAccounts.filter { + $0.type == .onMyMac || $0.type == .cloudKit + } + + let showAccountColumn = directReadingAccounts.count > 1 + let cutoffDate = Calendar.current.date(byAdding: .month, value: -monthThreshold, to: Date()) + + var rows = [DinosaurRow]() + + for account in directReadingAccounts { + let latestDates: [String: Date] + do { + latestDates = try await account.fetchLastUpdateDates() + } catch { + continue + } + + for feed in account.flattenedFeeds() { + let latestDate = latestDates[feed.feedID] + + let isDinosaur: Bool + if let latestDate, let cutoffDate { + isDinosaur = latestDate < cutoffDate + } else if latestDate == nil { + isDinosaur = true + } else { + isDinosaur = false + } + + if isDinosaur { + let row = DinosaurRow( + id: feed.url + account.accountID, + feed: feed, + account: account, + accountName: account.nameForDisplay, + feedName: feed.nameForDisplay, + feedURL: feed.url, + lastArticleDate: latestDate, + lastResponseCode: feed.lastResponseCode + ) + rows.append(row) + } + } + } + + return DinosaursFeedProvider(rows: rows, showAccountColumn: showAccountColumn) + } +} diff --git a/Mac/Dinosaurs/DinosaursView.swift b/Mac/Dinosaurs/DinosaursView.swift new file mode 100644 index 000000000..5170e0beb --- /dev/null +++ b/Mac/Dinosaurs/DinosaursView.swift @@ -0,0 +1,221 @@ +// +// DinosaursView.swift +// NetNewsWire +// +// Created by Brent Simmons on 5/31/26. +// + +@preconcurrency import AppKit +import SwiftUI +import Account + +struct DinosaursView: View { + + @State private var monthThreshold = 3 + @State private var monthThresholdText = "3" + @State private var rows = [DinosaurRow]() + @State private var showAccountColumn = false + @State private var selection = Set() + @State private var sortOrder = [KeyPathComparator(\DinosaurRow.feedName)] + @State private var showDeleteConfirmation = false + + private static let dateFormatter: DateFormatter = { + let formatter = DateFormatter() + formatter.dateStyle = .medium + formatter.timeStyle = .none + return formatter + }() + + var body: some View { + VStack(spacing: 0) { + filterBar + Divider() + table + Divider() + buttonBar + } + .task { + await fetchRows() + } + } + + private var filterBar: some View { + HStack { + Text("Show feeds that haven’t updated in", comment: "Dinosaurs filter prefix") + TextField("", text: $monthThresholdText) + .frame(width: 36) + .multilineTextAlignment(.center) + .onSubmit { + if let value = Int(monthThresholdText), value > 0 { + monthThreshold = value + Task { + await fetchRows() + } + } else { + monthThresholdText = "\(monthThreshold)" + } + } + Text("months", comment: "Dinosaurs filter unit") + Spacer() + } + .padding(12) + } + + private var table: some View { + Table(rows, selection: $selection, sortOrder: $sortOrder) { + TableColumn(Text("Name", comment: "Dinosaurs table column"), value: \.feedName) + .width(min: 100, ideal: 200) + TableColumn(Text("URL", comment: "Dinosaurs table column"), value: \.feedURL) + .width(min: 100, ideal: 200) + if showAccountColumn { + TableColumn(Text("Account", comment: "Dinosaurs table column"), value: \.accountName) + .width(min: 80, ideal: 120) + } + TableColumn(Text("Last Article", comment: "Dinosaurs table column"), value: \.lastArticleDate, comparator: OptionalDateComparator()) { row in + Text(row.lastArticleDate.map { Self.dateFormatter.string(from: $0) } ?? "—") + } + .width(min: 80, ideal: 120) + TableColumn(Text("Last Response", comment: "Dinosaurs table column"), value: \.lastResponseCode, comparator: OptionalIntComparator()) { row in + Text(row.lastResponseCode.map { "\($0)" } ?? "—") + } + .width(min: 60, ideal: 80) + } + .onChange(of: sortOrder) { + rows.sort(using: sortOrder) + } + } + + private var buttonBar: some View { + HStack { + Button(NSLocalizedString("Select in Sidebar", comment: "Dinosaurs button")) { + selectInSidebar() + } + .disabled(selection.count != 1) + + Button(NSLocalizedString("Delete…", comment: "Dinosaurs button")) { + showDeleteConfirmation = true + } + .disabled(selection.isEmpty) + + Button(NSLocalizedString("Go to Home Page", comment: "Dinosaurs button")) { + goToHomePage() + } + .disabled(selection.isEmpty) + + Spacer() + } + .padding(12) + .alert(NSLocalizedString("Delete Feeds", comment: "Dinosaurs delete confirmation title"), isPresented: $showDeleteConfirmation) { + Button(NSLocalizedString("Cancel", comment: "Dinosaurs delete confirmation button"), role: .cancel) {} + Button(NSLocalizedString("Delete", comment: "Dinosaurs delete confirmation button"), role: .destructive) { + deleteSelectedFeeds() + } + } message: { + if selection.count == 1 { + if let row = selectedRows.first { + Text("Are you sure you want to delete the feed \(row.feedName)?", comment: "Dinosaurs delete confirmation message — single feed") + } + } else { + Text("Are you sure you want to delete \(selection.count) feeds?", comment: "Dinosaurs delete confirmation message — multiple feeds") + } + } + } + + private var selectedRows: [DinosaurRow] { + rows.filter { selection.contains($0.id) } + } + + private func fetchRows() async { + let provider = await DinosaursFeedProvider.fetch(monthThreshold: monthThreshold) + rows = provider.rows.sorted(using: sortOrder) + showAccountColumn = provider.showAccountColumn + selection.removeAll() + } + + private func selectInSidebar() { + guard let row = selectedRows.first else { + return + } + guard let mainWindowController = NSApp.mainWindow?.windowController as? MainWindowController else { + return + } + mainWindowController.selectFeedInSidebar(row.feed) + } + + private func deleteSelectedFeeds() { + for row in selectedRows { + let containers = row.account.existingContainers(withFeed: row.feed) + for container in containers { + row.account.removeFeed(row.feed, from: container) { _ in } + } + } + Task { + await fetchRows() + } + } + + private func goToHomePage() { + for row in selectedRows { + if let homePageURL = row.feed.homePageURL, let url = URL(string: homePageURL) { + NSWorkspace.shared.open(url) + } + } + } +} + +struct OptionalDateComparator: SortComparator { + var order: SortOrder = .forward + + func compare(_ lhs: Date?, _ rhs: Date?) -> ComparisonResult { + switch (lhs, rhs) { + case (nil, nil): + return .orderedSame + case (nil, _): + return order == .forward ? .orderedAscending : .orderedDescending + case (_, nil): + return order == .forward ? .orderedDescending : .orderedAscending + case let (l?, r?): + let result = l.compare(r) + return order == .forward ? result : result.inverted + } + } +} + +struct OptionalIntComparator: SortComparator { + var order: SortOrder = .forward + + func compare(_ lhs: Int?, _ rhs: Int?) -> ComparisonResult { + switch (lhs, rhs) { + case (nil, nil): + return .orderedSame + case (nil, _): + return order == .forward ? .orderedAscending : .orderedDescending + case (_, nil): + return order == .forward ? .orderedDescending : .orderedAscending + case let (l?, r?): + let result: ComparisonResult + if l < r { + result = .orderedAscending + } else if l > r { + result = .orderedDescending + } else { + result = .orderedSame + } + return order == .forward ? result : result.inverted + } + } +} + +private extension ComparisonResult { + + var inverted: ComparisonResult { + switch self { + case .orderedAscending: + return .orderedDescending + case .orderedDescending: + return .orderedAscending + case .orderedSame: + return .orderedSame + } + } +} diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index 9a102444e..b34decfd0 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -126,6 +126,10 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations return sidebarViewController?.selectedObjects } + func selectFeedInSidebar(_ feed: Feed) { + sidebarViewController?.selectFeed(feed) + } + func handle(_ response: UNNotificationResponse) { let userInfo = response.notification.request.content.userInfo guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable: Any] else { return } diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift index 838b5b012..19fb035ec 100644 --- a/Modules/Account/Sources/Account/Account.swift +++ b/Modules/Account/Sources/Account/Account.swift @@ -884,6 +884,11 @@ public enum FetchType { try database.fetchAllArticlesCount(feedIDs: flattenedFeedsIDs) } + /// Returns a dictionary of feedID → latest article date for all feeds with articles. + public func fetchLastUpdateDates() async throws -> [String: Date] { + try await database.fetchLastUpdateDates() + } + public func fetchUnreadCountForTodayAsync() async throws -> Int { try await database.fetchUnreadCountForTodayAsync(feedIDs: flattenedFeedsIDs) } diff --git a/Modules/Account/Sources/Account/DataExtensions.swift b/Modules/Account/Sources/Account/DataExtensions.swift index d0b8ac375..60d64c7f6 100644 --- a/Modules/Account/Sources/Account/DataExtensions.swift +++ b/Modules/Account/Sources/Account/DataExtensions.swift @@ -33,6 +33,7 @@ public extension Feed { case externalID case folderRelationship case lastCheckDate + case lastResponseCode } } diff --git a/Modules/Account/Sources/Account/Feed.swift b/Modules/Account/Sources/Account/Feed.swift index c732b74bd..16a758b5f 100644 --- a/Modules/Account/Sources/Account/Feed.swift +++ b/Modules/Account/Sources/Account/Feed.swift @@ -189,6 +189,17 @@ import Articles settings.lastCheckDate = newValue } } + + /// HTTP status code from the most recent feed download attempt. + public var lastResponseCode: Int? { + get { + settings.lastResponseCode + } + set { + settings.lastResponseCode = newValue + } + } + // MARK: - DisplayNameProvider public var nameForDisplay: String { diff --git a/Modules/Account/Sources/Account/FeedSettings.swift b/Modules/Account/Sources/Account/FeedSettings.swift index d28e1366d..8a583638b 100644 --- a/Modules/Account/Sources/Account/FeedSettings.swift +++ b/Modules/Account/Sources/Account/FeedSettings.swift @@ -149,6 +149,16 @@ import Articles } } + /// HTTP status code from the most recent feed download attempt. + var lastResponseCode: Int? { + didSet { + if lastResponseCode != oldValue { + database.setInt(lastResponseCode, for: feedURL, column: .lastResponseCode) + postSettingDidChange(.lastResponseCode) + } + } + } + /// Create from database row (bulk load at startup). init(feedURL: String, row: FeedSettingsDatabase.Row, database: FeedSettingsDatabase) { self.feedURL = feedURL @@ -168,6 +178,7 @@ import Articles self.externalID = row.externalID self.folderRelationship = row.folderRelationship self.lastCheckDate = row.lastCheckDate + self.lastResponseCode = row.lastResponseCode } /// Create for a new feed not yet in the database. diff --git a/Modules/Account/Sources/Account/FeedSettingsDatabase.swift b/Modules/Account/Sources/Account/FeedSettingsDatabase.swift index 539e4fe3d..d2703293e 100644 --- a/Modules/Account/Sources/Account/FeedSettingsDatabase.swift +++ b/Modules/Account/Sources/Account/FeedSettingsDatabase.swift @@ -31,6 +31,7 @@ final class FeedSettingsDatabase: Sendable { case externalID case folderRelationship case lastCheckDate + case lastResponseCode } struct Row { @@ -49,6 +50,7 @@ final class FeedSettingsDatabase: Sendable { let externalID: String? let folderRelationship: [String: String]? let lastCheckDate: Date? + let lastResponseCode: Int? } let databasePath: String @@ -63,6 +65,9 @@ final class FeedSettingsDatabase: Sendable { self.database = FMDatabase.openAndSetUpDatabase(path: databasePath) serialDispatchQueue.sync { [database] in database.runCreateStatements(Self.tableCreationStatements) + if !database.columnExists("lastResponseCode", inTableWithName: "feedSettings") { + database.executeStatements("ALTER TABLE feedSettings ADD COLUMN lastResponseCode INTEGER;") + } } vacuumIfNeeded() } @@ -159,6 +164,19 @@ final class FeedSettingsDatabase: Sendable { } } + // MARK: - Int + + func setInt(_ value: Int?, for feedURL: String, column: Column) { + let name = column.rawValue + serialDispatchQueue.async { + if let value { + self.database.executeUpdate("UPDATE feedSettings SET \(name) = ? WHERE feedURL = ?;", withArgumentsIn: [value, feedURL]) + } else { + self.database.executeUpdate("UPDATE feedSettings SET \(name) = NULL WHERE feedURL = ?;", withArgumentsIn: [feedURL]) + } + } + } + // MARK: - Date func setDate(_ value: Date?, for feedURL: String, column: Column) { @@ -253,7 +271,7 @@ final class FeedSettingsDatabase: Sendable { private extension FeedSettingsDatabase { static let tableCreationStatements = """ - CREATE TABLE IF NOT EXISTS feedSettings (feedURL TEXT PRIMARY KEY, feedID TEXT NOT NULL DEFAULT '', homePageURL TEXT, iconURL TEXT, faviconURL TEXT, editedName TEXT, contentHash TEXT, newArticleNotificationsEnabled INTEGER NOT NULL DEFAULT 0, readerViewAlwaysEnabled INTEGER NOT NULL DEFAULT 0, authors TEXT, conditionalGetInfoLastModified TEXT, conditionalGetInfoEtag TEXT, conditionalGetInfoDate REAL, cacheControlInfoDateCreated REAL, cacheControlInfoMaxAge REAL, externalID TEXT, folderRelationship TEXT, lastCheckDate REAL); + CREATE TABLE IF NOT EXISTS feedSettings (feedURL TEXT PRIMARY KEY, feedID TEXT NOT NULL DEFAULT '', homePageURL TEXT, iconURL TEXT, faviconURL TEXT, editedName TEXT, contentHash TEXT, newArticleNotificationsEnabled INTEGER NOT NULL DEFAULT 0, readerViewAlwaysEnabled INTEGER NOT NULL DEFAULT 0, authors TEXT, conditionalGetInfoLastModified TEXT, conditionalGetInfoEtag TEXT, conditionalGetInfoDate REAL, cacheControlInfoDateCreated REAL, cacheControlInfoMaxAge REAL, externalID TEXT, folderRelationship TEXT, lastCheckDate REAL, lastResponseCode INTEGER); """ func row(from resultSet: FMResultSet) -> Row { @@ -289,6 +307,11 @@ private extension FeedSettingsDatabase { lastCheckDate = Date(timeIntervalSinceReferenceDate: resultSet.double(forColumn: Column.lastCheckDate.rawValue)) } + var lastResponseCode: Int? + if !resultSet.columnIsNull(Column.lastResponseCode.rawValue) { + lastResponseCode = Int(resultSet.int(forColumn: Column.lastResponseCode.rawValue)) + } + return Row( feedID: resultSet.swiftString(forColumn: Column.feedID.rawValue) ?? "", homePageURL: resultSet.swiftString(forColumn: Column.homePageURL.rawValue), @@ -304,7 +327,8 @@ private extension FeedSettingsDatabase { cacheControlInfo: cacheControlInfo, externalID: resultSet.swiftString(forColumn: Column.externalID.rawValue), folderRelationship: folderRelationship, - lastCheckDate: lastCheckDate + lastCheckDate: lastCheckDate, + lastResponseCode: lastResponseCode ) } } diff --git a/Modules/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift b/Modules/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift index c3900c2a7..6689ec099 100644 --- a/Modules/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift +++ b/Modules/Account/Sources/Account/LocalAccount/LocalAccountRefresher.swift @@ -240,6 +240,8 @@ import os return } + feed.lastResponseCode = httpResponse.statusCode + let statusIsOK = httpResponse.statusIsOK let statusIsOKOrNotModified = statusIsOK || httpResponse.statusCode == HTTPResponseCode.notModified guard statusIsOKOrNotModified else { diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift index dac7b31bd..cf9d411af 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift @@ -151,6 +151,16 @@ public struct ArticleChanges: Sendable { return try articlesTable.fetchArticlesMatchingWithArticleIDs(searchString, articleIDs) } + /// Returns a dictionary of feedID → latest article date for all feeds with articles. + public func fetchLastUpdateDates() async throws -> [String: Date] { + Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)") + return try await withCheckedThrowingContinuation { continuation in + articlesTable.fetchLastUpdateDatesAsync { result in + continuation.resume(with: result) + } + } + } + // MARK: - Fetching Articles Async public func fetchArticlesAsync(feedID: String) async throws -> Set
{ diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift index 3bd9c7b95..724fe547a 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift @@ -112,6 +112,24 @@ final class ArticlesTable: DatabaseTable, Sendable { return try fetchArticlesCount { self.fetchAllArticlesCount(feedIDs, $0) } } + // MARK: - Fetching Last Update Dates + + func fetchLastUpdateDatesAsync(_ completion: @escaping @Sendable (Result<[String: Date], DatabaseError>) -> Void) { + queue.runInDatabase { databaseResult in + switch databaseResult { + case .success(let database): + let result = self.fetchLastUpdateDates(database) + DispatchQueue.main.async { + completion(.success(result)) + } + case .failure(let databaseError): + DispatchQueue.main.async { + completion(.failure(databaseError)) + } + } + } + } + // MARK: - Fetching Search Articles func fetchArticlesMatching(_ searchString: String) throws -> Set
{ @@ -986,6 +1004,26 @@ nonisolated private extension ArticlesTable { return articles.filter { articleIDs.contains($0.articleID) } } + func fetchLastUpdateDates(_ database: FMDatabase) -> [String: Date] { + guard let resultSet = database.executeQuery("SELECT feedID, MAX(coalesce(datePublished, dateModified)) as latestDate FROM articles GROUP BY feedID;", withArgumentsIn: []) else { + return [:] + } + defer { + resultSet.close() + } + + var result = [String: Date]() + while resultSet.next() { + guard let feedID = resultSet.string(forColumn: "feedID") else { + continue + } + if !resultSet.columnIsNull("latestDate") { + result[feedID] = resultSet.date(forColumn: "latestDate") + } + } + return result + } + // MARK: - Saving Parsed Items func callUpdateArticlesCompletionBlock(_ newArticles: Set
?, _ updatedArticles: Set
?, _ deletedArticles: Set
?, _ completion: @escaping UpdateArticlesCompletionBlock) {