add option to sort headlines by feed-specified date (bump schema)

This commit is contained in:
Andrew Dolgov 2010-11-10 13:56:42 +03:00
parent 5414ad4c80
commit b3990c92e7
8 changed files with 53 additions and 13 deletions

View file

@ -313,28 +313,34 @@
$override_order = false;
if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
$date_sort_field = "updated";
} else {
$date_sort_field = "date_entered";
}
switch ($order_by) {
case "date":
if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
$override_order = "date_entered";
$override_order = "$date_sort_field";
} else {
$override_order = "date_entered DESC";
$override_order = "$date_sort_field DESC";
}
break;
case "title":
if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
$override_order = "title DESC, date_entered";
$override_order = "title DESC, $date_sort_field";
} else {
$override_order = "title, date_entered DESC";
$override_order = "title, $date_sort_field DESC";
}
break;
case "score":
if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
$override_order = "score, date_entered";
$override_order = "score, $date_sort_field";
} else {
$override_order = "score DESC, date_entered DESC";
$override_order = "score DESC, $date_sort_field DESC";
}
break;
}

View file

@ -3460,10 +3460,16 @@
$query_strategy_part = "id > 0"; // dumb
}
if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
$date_sort_field = "updated";
} else {
$date_sort_field = "date_entered";
}
if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
$order_by = "date_entered";
$order_by = "$date_sort_field";
} else {
$order_by = "date_entered DESC";
$order_by = "$date_sort_field DESC";
}
if ($view_mode != "noscores") {
@ -3593,9 +3599,15 @@
if (!$limit) $limit = 30;
if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
$date_sort_field = "updated";
} else {
$date_sort_field = "date_entered";
}
$qfh_ret = queryFeedHeadlines($link, $feed,
$limit, $view_mode, $is_cat, $search, $search_mode,
$match_on, "date_entered DESC", 0, $owner_uid);
$match_on, "$date_sort_field DESC", 0, $owner_uid);
$result = $qfh_ret[0];
$feed_title = htmlspecialchars($qfh_ret[1]);

View file

@ -20,7 +20,7 @@
"PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP",
"BLACKLISTED_TAGS", "ENABLE_FEED_ICONS", "ENABLE_API_ACCESS",
"UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL",
"MARK_UNREAD_ON_UPDATE", "USER_TIMEZONE");
"MARK_UNREAD_ON_UPDATE", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE");
if (FORCE_ARTICLE_PURGE != 0) {
array_push($prefs_blacklist, "PURGE_OLD_DAYS");

View file

@ -2,7 +2,7 @@
require_once "functions.php";
define('EXPECTED_CONFIG_VERSION', 19);
define('SCHEMA_VERSION', 72);
define('SCHEMA_VERSION', 73);
if (!file_exists("config.php")) {
print "<b>Fatal Error</b>: You forgot to copy

View file

@ -245,7 +245,7 @@ create table ttrss_tags (id integer primary key auto_increment,
create table ttrss_version (schema_version int not null) TYPE=InnoDB DEFAULT CHARSET=UTF8;
insert into ttrss_version values (72);
insert into ttrss_version values (73);
create table ttrss_enclosures (id integer primary key auto_increment,
content_url text not null,
@ -406,6 +406,9 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
'Use feed-specified date to sort headlines instead of local import date.');
create table ttrss_user_prefs (
owner_uid integer not null,
pref_name varchar(250),

View file

@ -217,7 +217,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 (72);
insert into ttrss_version values (73);
create table ttrss_enclosures (id serial not null primary key,
content_url text not null,
@ -370,6 +370,9 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
'Use feed-specified date to sort headlines instead of local import date.');
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,

View file

@ -0,0 +1,8 @@
begin;
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
'Use feed-specified date to sort headlines instead of local import date.');
update ttrss_version set schema_version = 73;
commit;

View file

@ -0,0 +1,8 @@
begin;
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
'Use feed-specified date to sort headlines instead of local import date.');
update ttrss_version set schema_version = 73;
commit;