summaryrefslogtreecommitdiffstats
path: root/lib/private/BackgroundJob/JobList.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/BackgroundJob/JobList.php')
-rw-r--r--lib/private/BackgroundJob/JobList.php18
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 = [];