mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Rewrite article cleanup and update docs
This commit is contained in:
parent
fa5786a4cc
commit
02301b0dd9
3 changed files with 21 additions and 43 deletions
|
@ -385,7 +385,7 @@ Arsse/0.6.0 (Linux 4.15.0; x86_64; https://thearsse.com/)
|
|||
|------------------|-----------|
|
||||
| interval or null | `"PT24H"` |
|
||||
|
||||
How long to keep a newsfeed and its articles in the database after all its subscriptions have been deleted. Specifying `null` will retain unsubscribed newsfeeds forever, whereas an interval evaluating to zero (e.g. `"PT0S"`) will delete them immediately.
|
||||
How long to keep a newsfeed subscription and its articles in the database after it has been soft-deleted by its owner. Specifying `null` will retain unsubscribed newsfeeds forever, whereas an interval evaluating to zero (e.g. `"PT0S"`) will delete them immediately.
|
||||
|
||||
Note that articles of orphaned newsfeeds are still subject to the `purgeArticleUnread` threshold below.
|
||||
|
||||
|
@ -395,11 +395,9 @@ Note that articles of orphaned newsfeeds are still subject to the `purgeArticleU
|
|||
|------------------|---------|
|
||||
| interval or null | `"P7D"` |
|
||||
|
||||
How long to keep a an article in the database after all users subscribed to its newsfeed have read it. Specifying `null` will retain articles up to the `purgeArticlesUnread` threshold below, whereas an interval evaluating to zero (e.g. `"PT0S"`) will delete them immediately.
|
||||
How long to keep a an article in the database after it has been read. Specifying `null` will retain articles up to the `purgeArticlesUnread` threshold below, whereas an interval evaluating to zero (e.g. `"PT0S"`) will delete them immediately.
|
||||
|
||||
If an article is starred by any user, it is retained indefinitely regardless of this setting.
|
||||
|
||||
This setting also governs when an article is hidden from a user after being read by that user, regardless of its actual presence in the database.
|
||||
If an article is starred by its owner, it is retained indefinitely regardless of this setting.
|
||||
|
||||
### purgeArticlesUnread
|
||||
|
||||
|
@ -407,9 +405,9 @@ This setting also governs when an article is hidden from a user after being read
|
|||
|------------------|----------|
|
||||
| interval or null | `"P21D"` |
|
||||
|
||||
How long to keep a an article in the database regardless of whether any users have read it. Specifying `null` will retain articles forever, whereas an interval evaluating to zero (e.g. `"PT0S"`) will delete them immediately.
|
||||
How long to keep a an article in the database regardless of whether it has been read. Specifying `null` will retain articles forever, whereas an interval evaluating to zero (e.g. `"PT0S"`) will delete them immediately.
|
||||
|
||||
If an article is starred by any user, it is retained indefinitely regardless of this setting.
|
||||
If an article is starred by its owner, it is retained indefinitely regardless of this setting.
|
||||
|
||||
# Obsolete settings
|
||||
|
||||
|
|
|
@ -94,10 +94,10 @@ use JKingWeb\Arsse\Misc\ValueInfo as Value;
|
|||
/** @var string|null User-Agent string to use when fetching feeds from foreign servers */
|
||||
public $fetchUserAgentString = null;
|
||||
|
||||
/** @var \DateInterval|null When to delete a feed from the database after all its subscriptions have been deleted, as an ISO 8601 duration (default: 24 hours; null for never)
|
||||
/** @var \DateInterval|null When to delete a subscription from the database after it has been soft-deleted, as an ISO 8601 duration (default: 24 hours; null for never)
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations */
|
||||
public $purgeFeeds = "PT24H";
|
||||
/** @var \DateInterval|null When to delete an unstarred article in the database after it has been marked read by all users, as an ISO 8601 duration (default: 7 days; null for never)
|
||||
/** @var \DateInterval|null When to delete an unstarred article in the database after it has been marked read, as an ISO 8601 duration (default: 7 days; null for never)
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations */
|
||||
public $purgeArticlesRead = "P7D";
|
||||
/** @var \DateInterval|null When to delete an unstarred article in the database regardless of its read state, as an ISO 8601 duration (default: 21 days; null for never)
|
||||
|
|
|
@ -2043,40 +2043,18 @@ class Database {
|
|||
from arsse_articles join (
|
||||
SELECT article, max(id) as edition from arsse_editions group by article
|
||||
) as latest_editions on arsse_articles.id = latest_editions.article
|
||||
where feed = ? order by edition desc limit ?
|
||||
),
|
||||
target_articles as (
|
||||
SELECT
|
||||
id
|
||||
from arsse_articles
|
||||
join (
|
||||
select
|
||||
feed,
|
||||
count(*) as subs
|
||||
from arsse_subscriptions
|
||||
where feed = ?
|
||||
group by feed
|
||||
) as feed_stats on feed_stats.feed = arsse_articles.feed
|
||||
left join (
|
||||
select
|
||||
article,
|
||||
sum(case when starred = 1 and hidden = 0 then 1 else 0 end) as starred,
|
||||
sum(case when \"read\" = 1 or hidden = 1 then 1 else 0 end) as \"read\",
|
||||
max(arsse_marks.modified) as marked_date
|
||||
from arsse_marks
|
||||
group by article
|
||||
) as mark_stats on mark_stats.article = arsse_articles.id
|
||||
where
|
||||
coalesce(starred,0) = 0
|
||||
and (
|
||||
coalesce(marked_date,modified) <= ?
|
||||
or (
|
||||
coalesce(\"read\",0) = coalesce(subs,0)
|
||||
and coalesce(marked_date,modified) <= ?
|
||||
)
|
||||
)
|
||||
where subscription = ? order by edition desc limit ?
|
||||
)
|
||||
DELETE FROM arsse_articles WHERE id not in (select id from exempt_articles) and id in (select id from target_articles)",
|
||||
DELETE FROM
|
||||
arsse_articles
|
||||
where
|
||||
subscription = ?
|
||||
and starred = 0
|
||||
and (
|
||||
coalesce(marked,modified) <= ?
|
||||
or (\"read\" = 1 and coalesce(marked,modified) <= ?)
|
||||
)
|
||||
and id not in (select id from exempt_articles)",
|
||||
["int", "int", "int", "datetime", "datetime"]
|
||||
);
|
||||
$limitRead = null;
|
||||
|
@ -2087,11 +2065,13 @@ class Database {
|
|||
if (Arsse::$conf->purgeArticlesUnread) {
|
||||
$limitUnread = Date::sub(Arsse::$conf->purgeArticlesUnread);
|
||||
}
|
||||
$feeds = $this->db->query("SELECT id, size from arsse_feeds")->getAll();
|
||||
$deleted = 0;
|
||||
$tr = $this->begin();
|
||||
$feeds = $this->db->query("SELECT id, size from arsse_subscriptions")->getAll();
|
||||
foreach ($feeds as $feed) {
|
||||
$deleted += $query->run($feed['id'], $feed['size'], $feed['id'], $limitUnread, $limitRead)->changes();
|
||||
}
|
||||
$tr->commit();
|
||||
return (bool) $deleted;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue