From 931dcbc137e085cf6d07a4aa7ef3ca7f77450532 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 20 Jan 2009 11:01:22 +0100 Subject: [PATCH] feedbrowser_cache: store title; implement by-title search in feed browser --- functions.php | 22 ++++++++++++++++------ modules/pref-feed-browser.php | 6 +++--- sanity_check.php | 2 +- schema/ttrss_schema_mysql.sql | 3 ++- schema/ttrss_schema_pgsql.sql | 3 ++- schema/versions/mysql/52.sql | 5 +++++ schema/versions/pgsql/52.sql | 9 +++++++++ 7 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 schema/versions/mysql/52.sql create mode 100644 schema/versions/pgsql/52.sql diff --git a/functions.php b/functions.php index f11b91b7..5d965eed 100644 --- a/functions.php +++ b/functions.php @@ -5797,11 +5797,11 @@ function update_feedbrowser_cache($link) { - $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers + $result = db_query($link, "SELECT feed_url,title, COUNT(id) AS subscribers FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf WHERE tf.feed_url = ttrss_feeds.feed_url AND (private IS true OR feed_url LIKE '%:%@%/%')) - GROUP BY feed_url ORDER BY subscribers DESC LIMIT 200"); + GROUP BY feed_url, title ORDER BY subscribers DESC"); db_query($link, "BEGIN"); @@ -5812,11 +5812,21 @@ while ($line = db_fetch_assoc($result)) { $subscribers = db_escape_string($line["subscribers"]); $feed_url = db_escape_string($line["feed_url"]); + $title = db_escape_string($line["title"]); + + $tmp_result = db_query($link, "SELECT subscribers FROM + ttrss_feedbrowser_cache WHERE feed_url = '$feed_url'"); + + if (db_num_rows($tmp_result) == 0) { + + db_query($link, "INSERT INTO ttrss_feedbrowser_cache + (feed_url, title, subscribers) VALUES ('$feed_url', + '$title', '$subscribers')"); + + ++$count; + + } - db_query($link, "INSERT INTO ttrss_feedbrowser_cache - (feed_url, subscribers) VALUES ('$feed_url', '$subscribers')"); - - ++$count; } db_query($link, "COMMIT"); diff --git a/modules/pref-feed-browser.php b/modules/pref-feed-browser.php index 97fcda8f..710d14a2 100644 --- a/modules/pref-feed-browser.php +++ b/modules/pref-feed-browser.php @@ -127,14 +127,14 @@ if ($browser_search) { $search_qpart = " AND ( - UPPER(ttrss_feedbrowser_cache.feed_url) LIKE UPPER('%$browser_search%'))"; - //UPPER(title) LIKE UPPER('%$browser_search%'))"; + UPPER(ttrss_feedbrowser_cache.feed_url) LIKE UPPER('%$browser_search%') OR + UPPER(title) LIKE UPPER('%$browser_search%'))"; } else { $search_qpart = ""; } $result = db_query($link, "SELECT ttrss_feedbrowser_cache.feed_url, - subscribers + subscribers,title FROM ttrss_feedbrowser_cache WHERE diff --git a/sanity_check.php b/sanity_check.php index 48c98fa2..253d1ae2 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 18); - define('SCHEMA_VERSION', 51); + define('SCHEMA_VERSION', 52); if (!file_exists("config.php")) { print __("Fatal Error: You forgot to copy diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index c07782e3..9de6567a 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -224,7 +224,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) TYPE=InnoDB; -insert into ttrss_version values (51); +insert into ttrss_version values (52); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -379,6 +379,7 @@ create table ttrss_sessions (id varchar(250) unique not null primary key, create table ttrss_feedbrowser_cache ( feed_url text not null, + title text not null, subscribers integer not null); create table ttrss_labels2 (id integer not null primary key auto_increment, diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 8646632d..f5907210 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -200,7 +200,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (51); +insert into ttrss_version values (52); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -348,6 +348,7 @@ create function SUBSTRING_FOR_DATE(timestamp, int, int) RETURNS text AS 'SELECT create table ttrss_feedbrowser_cache ( feed_url text not null primary key, + title text not null, subscribers integer not null); create table ttrss_labels2 (id serial not null primary key, diff --git a/schema/versions/mysql/52.sql b/schema/versions/mysql/52.sql new file mode 100644 index 00000000..4d9b64eb --- /dev/null +++ b/schema/versions/mysql/52.sql @@ -0,0 +1,5 @@ +alter table ttrss_feedbrowser_cache add column title text; +update ttrss_feedbrowser_cache set title = ''; +alter table ttrss_feedbrowser_cache change title title text not null; + +update ttrss_version set schema_version = 52; diff --git a/schema/versions/pgsql/52.sql b/schema/versions/pgsql/52.sql new file mode 100644 index 00000000..f7165e79 --- /dev/null +++ b/schema/versions/pgsql/52.sql @@ -0,0 +1,9 @@ +begin; + +alter table ttrss_feedbrowser_cache add column title text; +update ttrss_feedbrowser_cache set title = ''; +alter table ttrss_feedbrowser_cache alter column title set not null; + +update ttrss_version set schema_version = 52; + +commit; -- 2.39.5