move order_by to SQL override logic into a separate function
This commit is contained in:
parent
48be005774
commit
dfa65e9374
|
@ -214,21 +214,7 @@ class API extends Handler {
|
|||
|
||||
$_SESSION['hasSandbox'] = $has_sandbox;
|
||||
|
||||
$skip_first_id_check = false;
|
||||
|
||||
$override_order = false;
|
||||
switch (clean($_REQUEST["order_by"])) {
|
||||
case "title":
|
||||
$override_order = "ttrss_entries.title, date_entered, updated";
|
||||
break;
|
||||
case "date_reverse":
|
||||
$override_order = "updated";
|
||||
$skip_first_id_check = true;
|
||||
break;
|
||||
case "feed_dates":
|
||||
$override_order = "updated DESC";
|
||||
break;
|
||||
}
|
||||
list($override_order, $skip_first_id_check) = Feeds::order_to_override_query(clean($_REQUEST["order_by"]));
|
||||
|
||||
/* do not rely on params below */
|
||||
|
||||
|
|
|
@ -529,21 +529,7 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
$reply['headlines'] = [];
|
||||
|
||||
$override_order = false;
|
||||
$skip_first_id_check = false;
|
||||
|
||||
switch ($order_by) {
|
||||
case "title":
|
||||
$override_order = "ttrss_entries.title, date_entered, updated";
|
||||
break;
|
||||
case "date_reverse":
|
||||
$override_order = "updated";
|
||||
$skip_first_id_check = true;
|
||||
break;
|
||||
case "feed_dates":
|
||||
$override_order = "updated DESC";
|
||||
break;
|
||||
}
|
||||
list($override_order, $skip_first_id_check) = Feeds::order_to_override_query($order_by);
|
||||
|
||||
$ret = $this->format_headlines_list($feed, $method,
|
||||
$view_mode, $limit, $cat_view, $offset,
|
||||
|
@ -2348,5 +2334,25 @@ class Feeds extends Handler_Protected {
|
|||
|
||||
return array($search_query_part, $search_words);
|
||||
}
|
||||
|
||||
static function order_to_override_query($order) {
|
||||
$query = "";
|
||||
$skip_first_id = false;
|
||||
|
||||
switch ($order) {
|
||||
case "title":
|
||||
$query = "ttrss_entries.title, date_entered, updated";
|
||||
break;
|
||||
case "date_reverse":
|
||||
$query = "updated";
|
||||
$skip_first_id = true;
|
||||
break;
|
||||
case "feed_dates":
|
||||
$query = "updated DESC";
|
||||
break;
|
||||
}
|
||||
|
||||
return [$query, $skip_first_id];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,24 +12,16 @@ class Handler_Public extends Handler {
|
|||
|
||||
if (!$limit) $limit = 60;
|
||||
|
||||
$date_sort_field = "date_entered DESC, updated DESC";
|
||||
list($override_order, $skip_first_id_check) = Feeds::order_to_override_query($order);
|
||||
|
||||
if ($feed == -2 && !$is_cat) {
|
||||
$date_sort_field = "last_published DESC";
|
||||
} else if ($feed == -1 && !$is_cat) {
|
||||
$date_sort_field = "last_marked DESC";
|
||||
}
|
||||
if (!$override_order) {
|
||||
$override_order = "date_entered DESC, updated DESC";
|
||||
|
||||
switch ($order) {
|
||||
case "title":
|
||||
$date_sort_field = "ttrss_entries.title, date_entered, updated";
|
||||
break;
|
||||
case "date_reverse":
|
||||
$date_sort_field = "updated";
|
||||
break;
|
||||
case "feed_dates":
|
||||
$date_sort_field = "updated DESC";
|
||||
break;
|
||||
if ($feed == -2 && !$is_cat) {
|
||||
$override_order = "last_published DESC";
|
||||
} else if ($feed == -1 && !$is_cat) {
|
||||
$override_order = "last_marked DESC";
|
||||
}
|
||||
}
|
||||
|
||||
$params = array(
|
||||
|
@ -39,7 +31,7 @@ class Handler_Public extends Handler {
|
|||
"view_mode" => $view_mode,
|
||||
"cat_view" => $is_cat,
|
||||
"search" => $search,
|
||||
"override_order" => $date_sort_field,
|
||||
"override_order" => $override_order,
|
||||
"include_children" => true,
|
||||
"ignore_vfeed_group" => true,
|
||||
"offset" => $offset,
|
||||
|
|
Loading…
Reference in New Issue