public function getPendingJob($jobType = null, $includeFinished = false, $timestamp = null) {
		if (empty($jobType)) {
			return false;
		}

		if (empty($timestamp) || (!is_int($timestamp) || !ctype_digit($timestamp))) {
			$timestamp = strtotime('-15 minute');
		}

		$fetchedTime = date('Y-m-d H:i:s', $timestamp);
		$fields = [
			$this->alias . '.jobtype',
			$this->alias . '.created',
			$this->alias . '.status',
			$this->alias . '.age',
			$this->alias . '.fetched',
			$this->alias . '.progress',
			$this->alias . '.completed',
			$this->alias . '.reference',
			$this->alias . '.failed',
			$this->alias . '.failure_message'
		];
		$conditions = [
			'OR' => [
				[ // NOT_READY
					$this->alias . '.notbefore > NOW()',
				],
				[ // NOT_STARTED
					$this->alias . '.fetched' => null,
				],
				[ // IN_PROGRESS
					'AND' => [
						$this->alias . '.fetched NOT' => null,
						$this->alias . '.fetched >' => $fetchedTime,
						$this->alias . '.completed' => null,
						$this->alias . '.failed' => 0,
					],
				]
			],
			$this->alias . '.jobtype' => $jobType,
		];
		if ($includeFinished) {
			$conditions['OR'][] = [ // FAILED
				'AND' => [
					$this->alias . '.fetched NOT' => null,
					$this->alias . '.fetched >' => $fetchedTime,
					$this->alias . '.completed' => null,
					$this->alias . '.failed >' => 0,
				],
			];
			$conditions['OR'][] = [ // COMPLETED
				'AND' => [
					$this->alias . '.fetched NOT' => null,
					$this->alias . '.fetched >' => $fetchedTime,
					$this->alias . '.completed NOT' => null,
				],
			];
		}
		$order = [
			'FIELD(' . $this->alias . '__status' . ', \'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\', \'FAILED\', \'COMPLETED\')' => 'ASC',
			'CAST(' . $this->alias . '__age AS SIGNED)' => 'DESC',
			'CASE WHEN ' . $this->alias . '__status' . ' IN(\'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\') THEN ' . $this->alias . '.id END ASC',
			'CASE WHEN ' . $this->alias . '__status' . ' IN(\'FAILED\', \'COMPLETED\') THEN ' . $this->alias . '.id END DESC',
		];

		return $this->find('first', compact('fields', 'conditions', 'order'));
	}