mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
Properly fix 'trending' and 'recent' API bugs
Prior fixes either didn't fix these API points or broke the normal lists. This fix adds check to make sure we're in the right place and then does a specifc sql query for the API. We should be good now.
This commit is contained in:
parent
9faff9a428
commit
054180f69a
@ -678,7 +678,6 @@ class Pastes extends CI_Model
|
||||
$total_rows = $query->num_rows();
|
||||
|
||||
// query
|
||||
|
||||
if ($this->db->dbdriver == "postgre")
|
||||
{
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw FROM $TABLE WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $amount OFFSET $page";
|
||||
@ -712,6 +711,11 @@ class Pastes extends CI_Model
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw FROM $TABLE WHERE private = 0 ORDER BY created DESC LIMIT $amount OFFSET $page";
|
||||
}
|
||||
else
|
||||
if ($root == 'api/recent')
|
||||
{
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw FROM $TABLE WHERE private = 0 ORDER BY created DESC LIMIT 0,15";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw FROM $TABLE WHERE private = 0 ORDER BY created DESC LIMIT $page,$amount";
|
||||
}
|
||||
@ -808,6 +812,11 @@ class Pastes extends CI_Model
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM $TABLE WHERE private = 0 ORDER BY hits DESC, created DESC LIMIT $amount OFFSET $page";
|
||||
}
|
||||
else
|
||||
if ($root == "api/trending")
|
||||
{
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM $TABLE WHERE private = 0 ORDER BY hits DESC, created DESC LIMIT 0,15";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM $TABLE WHERE private = 0 ORDER BY hits DESC, created DESC LIMIT $page,$amount";
|
||||
}
|
||||
|
@ -53,7 +53,7 @@
|
||||
*
|
||||
* NOTE: If you change these, also change the error_reporting() code below
|
||||
*/
|
||||
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
|
||||
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user