Add option to flush all unread items after X days, default 45 days (avoid very large database)
This commit is contained in:
parent
5e0e079afa
commit
4313909052
@ -119,7 +119,8 @@ Router\get_action('config', function() {
|
||||
'values' => Model\Config\get_all() + array('csrf' => Model\Config\generate_csrf()),
|
||||
'languages' => Model\Config\get_languages(),
|
||||
'timezones' => Model\Config\get_timezones(),
|
||||
'autoflush_options' => Model\Config\get_autoflush_options(),
|
||||
'autoflush_read_options' => Model\Config\get_autoflush_read_options(),
|
||||
'autoflush_unread_options' => Model\Config\get_autoflush_unread_options(),
|
||||
'paging_options' => Model\Config\get_paging_options(),
|
||||
'theme_options' => Model\Config\get_themes(),
|
||||
'sorting_options' => Model\Config\get_sorting_directions(),
|
||||
|
@ -9,7 +9,8 @@ use PicoFarad\Template;
|
||||
// Display unread items
|
||||
Router\get_action('unread', function() {
|
||||
|
||||
Model\Item\autoflush();
|
||||
Model\Item\autoflush_read();
|
||||
Model\Item\autoflush_unread();
|
||||
|
||||
$order = Request\param('order', 'updated');
|
||||
$direction = Request\param('direction', Model\Config\get('items_sorting_direction'));
|
||||
|
@ -31,5 +31,6 @@ if ($update_interval !== null && $call_interval !== null && $limit === Model\Fee
|
||||
}
|
||||
|
||||
Model\Feed\refresh_all($limit);
|
||||
Model\Item\autoflush();
|
||||
Model\Item\autoflush_read();
|
||||
Model\Item\autoflush_unread();
|
||||
Model\Config\write_debug();
|
||||
|
@ -215,4 +215,5 @@ return array(
|
||||
// 'Default' => '',
|
||||
// 'Value required' => '',
|
||||
// 'Must be an integer' => '',
|
||||
// 'Remove automatically unread items' => '',
|
||||
);
|
||||
|
@ -215,4 +215,5 @@ return array(
|
||||
'Default' => 'Standard',
|
||||
'Value required' => 'Wert ist erforderlich',
|
||||
'Must be an integer' => 'Muss eine Ganzzahl sein',
|
||||
// 'Remove automatically unread items' => '',
|
||||
);
|
||||
|
@ -215,4 +215,5 @@ return array(
|
||||
// 'Default' => '',
|
||||
// 'Value required' => '',
|
||||
// 'Must be an integer' => '',
|
||||
// 'Remove automatically unread items' => '',
|
||||
);
|
||||
|
@ -215,4 +215,5 @@ return array(
|
||||
'Default' => 'Défaut',
|
||||
'Value required' => 'Value required',
|
||||
'Must be an integer' => 'Must be an integer',
|
||||
'Remove automatically unread items' => 'Supprimer automatiquement les éléments non lus',
|
||||
);
|
||||
|
@ -215,4 +215,5 @@ return array(
|
||||
// 'Default' => '',
|
||||
// 'Value required' => '',
|
||||
// 'Must be an integer' => '',
|
||||
// 'Remove automatically unread items' => '',
|
||||
);
|
||||
|
@ -215,4 +215,5 @@ return array(
|
||||
// 'Default' => '',
|
||||
// 'Value required' => '',
|
||||
// 'Must be an integer' => '',
|
||||
// 'Remove automatically unread items' => '',
|
||||
);
|
||||
|
@ -215,4 +215,5 @@ return array(
|
||||
// 'Default' => '',
|
||||
// 'Value required' => '',
|
||||
// 'Must be an integer' => '',
|
||||
// 'Remove automatically unread items' => '',
|
||||
);
|
||||
|
@ -9,7 +9,7 @@ use PicoDb\Database;
|
||||
use PicoFeed\Config as ReaderConfig;
|
||||
use PicoFeed\Logging;
|
||||
|
||||
const DB_VERSION = 29;
|
||||
const DB_VERSION = 30;
|
||||
const HTTP_USER_AGENT = 'Miniflux (http://miniflux.net)';
|
||||
|
||||
// Get PicoFeed config
|
||||
@ -121,8 +121,8 @@ function get_display_mode()
|
||||
);
|
||||
}
|
||||
|
||||
// Autoflush choices for items
|
||||
function get_autoflush_options()
|
||||
// Autoflush choices for read items
|
||||
function get_autoflush_read_options()
|
||||
{
|
||||
return array(
|
||||
'0' => t('Never'),
|
||||
@ -134,6 +134,18 @@ function get_autoflush_options()
|
||||
);
|
||||
}
|
||||
|
||||
// Autoflush choices for unread items
|
||||
function get_autoflush_unread_options()
|
||||
{
|
||||
return array(
|
||||
'0' => t('Never'),
|
||||
'15' => t('After %d days', 15),
|
||||
'30' => t('After %d days', 30),
|
||||
'45' => t('After %d days', 45),
|
||||
'60' => t('After %d days', 60),
|
||||
);
|
||||
}
|
||||
|
||||
// Number of items per pages
|
||||
function get_paging_options()
|
||||
{
|
||||
@ -271,6 +283,7 @@ function get_all()
|
||||
'language',
|
||||
'timezone',
|
||||
'autoflush',
|
||||
'autoflush_unread',
|
||||
'nocontent',
|
||||
'items_per_page',
|
||||
'theme',
|
||||
@ -293,6 +306,7 @@ function validate_modification(array $values)
|
||||
new Validators\Required('username', t('The user name is required')),
|
||||
new Validators\MaxLength('username', t('The maximum length is 50 characters'), 50),
|
||||
new Validators\Required('autoflush', t('Value required')),
|
||||
new Validators\Required('autoflush_unread', t('Value required')),
|
||||
new Validators\Required('items_per_page', t('Value required')),
|
||||
new Validators\Integer('items_per_page', t('Must be an integer')),
|
||||
new Validators\Required('theme', t('Value required')),
|
||||
|
@ -381,7 +381,7 @@ function mark_feed_as_read($feed_id)
|
||||
}
|
||||
|
||||
// Mark all read items to removed after X days
|
||||
function autoflush()
|
||||
function autoflush_read()
|
||||
{
|
||||
$autoflush = (int) Config\get('autoflush');
|
||||
|
||||
@ -406,6 +406,23 @@ function autoflush()
|
||||
}
|
||||
}
|
||||
|
||||
// Mark all unread items to removed after X days
|
||||
function autoflush_unread()
|
||||
{
|
||||
$autoflush = (int) Config\get('autoflush_unread');
|
||||
|
||||
if ($autoflush > 0) {
|
||||
|
||||
// Mark read items removed after X days
|
||||
Database::get('db')
|
||||
->table('items')
|
||||
->eq('bookmark', 0)
|
||||
->eq('status', 'unread')
|
||||
->lt('updated', strtotime('-'.$autoflush.'day'))
|
||||
->save(array('status' => 'removed', 'content' => ''));
|
||||
}
|
||||
}
|
||||
|
||||
// Update all items
|
||||
function update_all($feed_id, array $items, $enable_grabber = false)
|
||||
{
|
||||
|
@ -5,6 +5,11 @@ namespace Schema;
|
||||
use PDO;
|
||||
use Model\Config;
|
||||
|
||||
function version_30($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE config ADD COLUMN autoflush_unread INTEGER DEFAULT 45');
|
||||
}
|
||||
|
||||
function version_29($pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE config ADD COLUMN fever_token INTEGER DEFAULT "'.substr(Config\generate_token(), 0, 8).'"');
|
||||
|
@ -28,7 +28,10 @@
|
||||
<?= Helper\form_select('language', $languages, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Remove automatically read items'), 'autoflush') ?>
|
||||
<?= Helper\form_select('autoflush', $autoflush_options, $values, $errors) ?><br/>
|
||||
<?= Helper\form_select('autoflush', $autoflush_read_options, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Remove automatically unread items'), 'autoflush_unread') ?>
|
||||
<?= Helper\form_select('autoflush_unread', $autoflush_unread_options, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Items per page'), 'items_per_page') ?>
|
||||
<?= Helper\form_select('items_per_page', $paging_options, $values, $errors) ?><br/>
|
||||
|
Loading…
Reference in New Issue
Block a user