diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-05-23 12:30:26 +0200 |
---|---|---|
committer | Côme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com> | 2022-07-11 09:46:23 +0000 |
commit | 3d0117990749bebe5394ff664d62494ae9a6fa1e (patch) | |
tree | 0eafa0b6fcc4d8d15654254ddd03db5209842996 /lib/private | |
parent | 0b7779b6ff7dcb603d1088f3ea8fbf42ce5a98c4 (diff) | |
download | nextcloud-server-3d0117990749bebe5394ff664d62494ae9a6fa1e.tar.gz nextcloud-server-3d0117990749bebe5394ff664d62494ae9a6fa1e.zip |
Add command to list jobs
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/BackgroundJob/JobList.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index fa47f9b6daa..8ba993646a9 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -166,9 +166,25 @@ class JobList implements IJobList { * memory problems when creating too many instances. */ public function getAll() { + return $this->getJobs(null, null, 0); + } + + public function getJobs($job, ?int $limit, int $offset): array { $query = $this->connection->getQueryBuilder(); $query->select('*') - ->from('jobs'); + ->from('jobs') + ->setMaxResults($limit) + ->setFirstResult($offset); + + if ($job !== null) { + if ($job instanceof IJob) { + $class = get_class($job); + } else { + $class = $job; + } + $query->where($query->expr()->eq('class', $query->createNamedParameter($class))); + } + $result = $query->executeQuery(); $jobs = []; |