From d234a2e39d18e685f3ed76ceca2f30f3bfa0eb18 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 23 Jul 2008 04:55:35 +0100 Subject: [PATCH] new option: SYNC_COUNTERS (bump schema) --- backend.php | 6 ++++-- feedlist.js | 4 ++++ functions.php | 8 +++++++- localized_schema.php | 1 + sanity_check.php | 2 +- schema/ttrss_schema_mysql.sql | 4 +++- schema/ttrss_schema_pgsql.sql | 4 +++- schema/versions/mysql/38.sql | 3 +++ schema/versions/pgsql/38.sql | 3 +++ 9 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 schema/versions/mysql/38.sql create mode 100644 schema/versions/pgsql/38.sql diff --git a/backend.php b/backend.php index a73e5407..cc5fd46c 100644 --- a/backend.php +++ b/backend.php @@ -214,7 +214,8 @@ } } - if ($mode == "prefetch" && $csync) { + + if (get_pref($link, "SYNC_COUNTERS") || ($mode == "prefetch" && $csync)) { print ""; getAllCounters($link, $omode); print ""; @@ -299,7 +300,8 @@ $viewfeed_ctr_interval = 60; } - if (time() - $_SESSION["get_all_counters_stamp"] > $viewfeed_ctr_interval) { + if (get_pref($link, "SYNC_COUNTERS") || + time() - $_SESSION["get_all_counters_stamp"] > $viewfeed_ctr_interval) { print ""; getAllCounters($link, $omode, $feed); print ""; diff --git a/feedlist.js b/feedlist.js index 5ae60449..1f851e0e 100644 --- a/feedlist.js +++ b/feedlist.js @@ -542,7 +542,11 @@ function request_counters() { var date = new Date(); var timestamp = Math.round(date.getTime() / 1000); +// if (getInitParam("sync_counters") == "1" || +// timestamp - counters_last_request > 10) { + if (timestamp - counters_last_request > 10) { + debug("scheduling request of counters..."); window.setTimeout("request_counters_real()", 1000); counters_last_request = timestamp; diff --git a/functions.php b/functions.php index 04ddaadb..5a72f681 100644 --- a/functions.php +++ b/functions.php @@ -2227,7 +2227,10 @@ /* getting all counters is a resource intensive operation, so we * rate limit it a little bit */ - if (time() - $_SESSION["get_all_counters_stamp"] > 5) { + + + if (get_pref($link, "SYNC_COUNTERS") || + time() - $_SESSION["get_all_counters_stamp"] > 5) { if (!$omode) $omode = "flc"; @@ -3018,6 +3021,9 @@ print ""; + print ""; + print ""; } diff --git a/localized_schema.php b/localized_schema.php index 083e2eb2..9325160d 100644 --- a/localized_schema.php +++ b/localized_schema.php @@ -72,5 +72,6 @@ __("Automatically expand articles in combined mode"); __("Purge unread articles"); __("Show special feeds when hiding read feeds"); + __("Prefer more accurate feedlist counters to UI speed"); ?> diff --git a/sanity_check.php b/sanity_check.php index 383edab4..ee715a82 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 17); - define('SCHEMA_VERSION', 37); + define('SCHEMA_VERSION', 38); 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 d3082da0..59a8c83b 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -209,7 +209,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 (37); +insert into ttrss_version values (38); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -332,6 +332,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('VFEED_GROUP_BY_FEED', 1, 'false', 'Group headlines in virtual feeds',2, 'When this option is enabled, headlines in Special feeds and Labels are grouped by feeds'); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SYNC_COUNTERS', 1, 'false', 'Prefer more accurate feedlist counters to UI speed',3); + create table ttrss_user_prefs ( owner_uid integer not null, pref_name varchar(250), diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 6d70ddc6..c0cddfba 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -189,7 +189,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 (37); +insert into ttrss_version values (38); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -306,6 +306,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('VFEED_GROUP_BY_FEED', 1, 'false', 'Group headlines in virtual feeds',2, 'When this option is enabled, headlines in Special feeds and Labels are grouped by feeds'); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SYNC_COUNTERS', 1, 'false', 'Prefer more accurate feedlist counters to UI speed',3); + create table ttrss_user_prefs ( owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE, pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE, diff --git a/schema/versions/mysql/38.sql b/schema/versions/mysql/38.sql new file mode 100644 index 00000000..df544d03 --- /dev/null +++ b/schema/versions/mysql/38.sql @@ -0,0 +1,3 @@ +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SYNC_COUNTERS', 1, 'false', 'Prefer more accurate feedlist counters to UI speed',3); + +update ttrss_version set schema_version = 38; diff --git a/schema/versions/pgsql/38.sql b/schema/versions/pgsql/38.sql new file mode 100644 index 00000000..df544d03 --- /dev/null +++ b/schema/versions/pgsql/38.sql @@ -0,0 +1,3 @@ +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SYNC_COUNTERS', 1, 'false', 'Prefer more accurate feedlist counters to UI speed',3); + +update ttrss_version set schema_version = 38;