Fixing Trending & Recent API bug

Fixed Trending & Recent API bug

Fixing Trending & Recent API bug

Fixed Trending & Recent API bug
This commit is contained in:
filereal 2014-10-19 00:50:25 +05:00 committed by Kyle Laker
parent ac9ae70078
commit 8d7ff6ce46
2 changed files with 8 additions and 4 deletions

View File

@ -129,7 +129,7 @@ class Api extends Main
show_404(); show_404();
} }
$this->load->model('pastes'); $this->load->model('pastes');
$pastes = $this->pastes->getLists(); $pastes = $this->pastes->getLists('api/recent');
$pastes = $pastes['pastes']; $pastes = $pastes['pastes'];
$data = array(); $data = array();
foreach ($pastes as $paste) foreach ($pastes as $paste)
@ -153,7 +153,7 @@ class Api extends Main
show_404(); show_404();
} }
$this->load->model('pastes'); $this->load->model('pastes');
$pastes = $this->pastes->getTrends(); $pastes = $this->pastes->getTrends('api/trending',2);
$pastes = $pastes['pastes']; $pastes = $pastes['pastes'];
$data = array(); $data = array();
foreach ($pastes as $paste) foreach ($pastes as $paste)

View File

@ -470,6 +470,8 @@ class Pastes extends CI_Model
// query // query
if($this->db->dbdriver == "postgre") { if($this->db->dbdriver == "postgre") {
$sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $amount OFFSET $page"; $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $amount OFFSET $page";
} else if ($root == 'api/recent'){
$sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT 0,15";
} else { } else {
$sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $page,$amount"; $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $page,$amount";
} }
@ -551,6 +553,8 @@ class Pastes extends CI_Model
// query // query
if($this->db->dbdriver == "postgre") { if($this->db->dbdriver == "postgre") {
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $amount OFFSET $page"; $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) 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 pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT 0,15";
}else { }else {
$sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $page,$amount"; $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $page,$amount";
} }