add ttrss_filters2.last_triggered (bump schema version)

This commit is contained in:
Andrew Dolgov 2018-12-06 19:37:20 +03:00
parent a01c33d654
commit 3e4326e34d
8 changed files with 33 additions and 4 deletions

View File

@ -333,6 +333,7 @@ class Pref_Filters extends Handler_Protected {
$filter['name'] = $name[0]; $filter['name'] = $name[0];
$filter['param'] = $name[1]; $filter['param'] = $name[1];
$filter['checkbox'] = false; $filter['checkbox'] = false;
$filter['last_triggered'] = $line["last_triggered"] ? make_local_datetime($line["last_triggered"], false) : null;
$filter['enabled'] = $line["enabled"]; $filter['enabled'] = $line["enabled"];
$filter['rules'] = $this->getfilterrules_concise($line['id']); $filter['rules'] = $this->getfilterrules_concise($line['id']);

View File

@ -781,6 +781,12 @@ class RSSUtils {
$plugin->hook_filter_triggered($feed, $owner_uid, $article, $matched_filters, $matched_rules, $article_filters); $plugin->hook_filter_triggered($feed, $owner_uid, $article, $matched_filters, $matched_rules, $article_filters);
} }
$matched_filter_ids = implode(",", array_map(function($f) { return $f['id']; }, $matched_filters));
$fsth = $pdo->prepare("UPDATE ttrss_filters2 SET last_triggered = NOW() WHERE
id IN (?) AND owner_uid = ?");
$fsth->execute([$matched_filter_ids, $owner_uid]);
if (Debug::get_loglevel() >= Debug::$LOG_EXTENDED) { if (Debug::get_loglevel() >= Debug::$LOG_EXTENDED) {
Debug::log("matched filters: ", Debug::$LOG_VERBOSE); Debug::log("matched filters: ", Debug::$LOG_VERBOSE);

View File

@ -1,6 +1,6 @@
<?php <?php
define('EXPECTED_CONFIG_VERSION', 26); define('EXPECTED_CONFIG_VERSION', 26);
define('SCHEMA_VERSION', 134); define('SCHEMA_VERSION', 135);
define('LABEL_BASE_INDEX', -1024); define('LABEL_BASE_INDEX', -1024);
define('PLUGIN_FEED_BASE_INDEX', -128); define('PLUGIN_FEED_BASE_INDEX', -128);

View File

@ -39,6 +39,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
const feed = this.model.store.getValue(item, 'feed'); const feed = this.model.store.getValue(item, 'feed');
const inverse = this.model.store.getValue(item, 'inverse'); const inverse = this.model.store.getValue(item, 'inverse');
const last_triggered = this.model.store.getValue(item, 'last_triggered');
if (feed) if (feed)
label += " (" + __("in") + " " + feed + ")"; label += " (" + __("in") + " " + feed + ")";
@ -46,6 +47,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
if (inverse) if (inverse)
label += " (" + __("Inverse") + ")"; label += " (" + __("Inverse") + ")";
if (last_triggered)
label += " — " + last_triggered;
return label; return label;
}, },
getIconClass: function (item, opened) { getIconClass: function (item, opened) {

View File

@ -244,6 +244,7 @@ create table ttrss_filters2(id integer primary key auto_increment,
inverse bool not null default false, inverse bool not null default false,
title varchar(250) not null default '', title varchar(250) not null default '',
order_id integer not null default 0, order_id integer not null default 0,
last_triggered datetime default null,
foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8; foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
create table ttrss_filters2_rules(id integer primary key auto_increment, create table ttrss_filters2_rules(id integer primary key auto_increment,
@ -284,7 +285,7 @@ create table ttrss_tags (id integer primary key auto_increment,
create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8; create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
insert into ttrss_version values (134); insert into ttrss_version values (135);
create table ttrss_enclosures (id integer primary key auto_increment, create table ttrss_enclosures (id integer primary key auto_increment,
content_url text not null, content_url text not null,

View File

@ -239,6 +239,7 @@ create table ttrss_filters2(id serial not null primary key,
inverse boolean not null default false, inverse boolean not null default false,
title varchar(250) not null default '', title varchar(250) not null default '',
order_id integer not null default 0, order_id integer not null default 0,
last_triggered timestamp default null,
enabled boolean not null default true); enabled boolean not null default true);
create table ttrss_filters2_rules(id serial not null primary key, create table ttrss_filters2_rules(id serial not null primary key,
@ -266,7 +267,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
create table ttrss_version (schema_version int not null); create table ttrss_version (schema_version int not null);
insert into ttrss_version values (134); insert into ttrss_version values (135);
create table ttrss_enclosures (id serial not null primary key, create table ttrss_enclosures (id serial not null primary key,
content_url text not null, content_url text not null,

View File

@ -0,0 +1,8 @@
begin;
alter table ttrss_filters2 add column last_triggered datetime;
alter table ttrss_filters2 alter column last_triggered set default null;
update ttrss_version set schema_version = 135;
commit;

View File

@ -0,0 +1,8 @@
begin;
alter table ttrss_filters2 add column last_triggered timestamp;
alter table ttrss_filters2 alter column last_triggered set default null;
update ttrss_version set schema_version = 135;
commit;