*/
class SourceManager extends APIModule {
- public function getSources($criteria = [], $limit_val = null) {
+ public function getSources($criteria = [], $limit_val = null, $offset_val = 0) {
$limit = '';
if(is_int($limit_val) && $limit_val > 0) {
$limit = ' LIMIT ' . $limit_val;
}
+ $offset = '';
+ if (is_int($offset_val) && $offset_val > 0) {
+ $offset = ' OFFSET ' . $offset_val;
+ }
$where = Database::getWhere($criteria, true);
$sql = 'SELECT DISTINCT
sres.fileset, sres.client, sres.job, jres.starttime, jres.endtime, ores.jobid, jres.jobstatus
AND sres.fileset = ores.fileset
AND jres.Type = \'B\'
' . (!empty($where['where']) ? ' AND ' . $where['where'] : '') . '
- ORDER BY sres.fileset ASC, sres.client ASC, sres.job ASC, jres.starttime ASC ' . $limit;
+ ORDER BY sres.fileset ASC, sres.client ASC, sres.job ASC, jres.starttime ASC ' . $limit . $offset;
$connection = SourceRecord::finder()->getDbConnection();
$connection->setActive(true);
public function get() {
$misc = $this->getModule('misc');
- $limit = $this->Request->contains('limit') ? (int)$this->Request['limit'] : 0;
+ $limit = $this->Request->contains('limit') && $misc->isValidInteger($this->Request['limit']) ? (int)$this->Request['limit'] : 0;
+ $offset = $this->Request->contains('offset') && $misc->isValidInteger($this->Request['offset']) ? (int)$this->Request['offset'] : 0;
$job = $this->Request->contains('job') && $misc->isValidName($this->Request['job']) ? $this->Request['job'] : '';
$client = $this->Request->contains('client') && $misc->isValidName($this->Request['client']) ? $this->Request['client'] : '';
$fileset = $this->Request->contains('fileset') && $misc->isValidName($this->Request['fileset']) ? $this->Request['fileset'] : '';
}
}
- $sources = $this->getModule('source')->getSources($params, $limit);
+ $sources = $this->getModule('source')->getSources($params, $limit, $offset);
$this->output = $sources;
$this->error = SourceError::ERROR_NO_ERRORS;
}