Delete articles older than the 90-day window.
This commit is contained in:
parent
416c4c6b35
commit
47f3e863b6
@ -216,6 +216,7 @@ public final class ArticlesDatabase {
|
||||
|
||||
/// Calls the various clean-up functions.
|
||||
public func cleanupDatabaseAtStartup(subscribedToWebFeedIDs: Set<String>) {
|
||||
articlesTable.deleteOldArticles()
|
||||
articlesTable.deleteArticlesNotInSubscribedToFeedIDs(subscribedToWebFeedIDs)
|
||||
}
|
||||
}
|
||||
|
@ -458,6 +458,24 @@ final class ArticlesTable: DatabaseTable {
|
||||
|
||||
// MARK: - Cleanup
|
||||
|
||||
/// Delete articles that we won’t show in the UI any longer
|
||||
/// — their arrival date is before our 90-day recency window.
|
||||
/// Keep all starred articles, no matter their age.
|
||||
func deleteOldArticles() {
|
||||
queue.runInTransaction { databaseResult in
|
||||
|
||||
func makeDatabaseCalls(_ database: FMDatabase) {
|
||||
let sql = "delete from articles where articleID in (select articleID from articles natural join statuses where dateArrived<? and starred=0);"
|
||||
let parameters = [self.articleCutoffDate] as [Any]
|
||||
database.executeUpdate(sql, withArgumentsIn: parameters)
|
||||
}
|
||||
|
||||
if let database = databaseResult.database {
|
||||
makeDatabaseCalls(database)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Delete articles from feeds that are no longer in the current set of subscribed-to feeds.
|
||||
/// This deletes from the articles and articleStatuses tables,
|
||||
/// and, via a trigger, it also deletes from the search index.
|
||||
|
Loading…
x
Reference in New Issue
Block a user