summaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-05-31 17:15:26 +0200
committerJoas Schilling <coding@schilljs.com>2021-10-14 09:57:16 +0200
commit9cd9f4b4bc87133cf446746295e9730c244b3a49 (patch)
tree04a08e521e533e61e76f8d2ff3534cf2a6b0db11 /core/Command
parente2a7482b490b6b3e5143b4678d88867a6398b248 (diff)
downloadnextcloud-server-9cd9f4b4bc87133cf446746295e9730c244b3a49.tar.gz
nextcloud-server-9cd9f4b4bc87133cf446746295e9730c244b3a49.zip
Move queries to the joblist
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/Background/Job.php25
1 files changed, 2 insertions, 23 deletions
diff --git a/core/Command/Background/Job.php b/core/Command/Background/Job.php
index 2a96744310b..62f2ea823dd 100644
--- a/core/Command/Background/Job.php
+++ b/core/Command/Background/Job.php
@@ -27,8 +27,6 @@ namespace OC\Core\Command\Background;
use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\IJobList;
-use OCP\DB\QueryBuilder\IQueryBuilder;
-use OCP\IDBConnection;
use OCP\ILogger;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -39,17 +37,13 @@ use Symfony\Component\Console\Output\OutputInterface;
class Job extends Command {
/** @var IJobList */
protected $jobList;
- /** @var IDBConnection */
- protected $connection;
/** @var ILogger */
protected $logger;
public function __construct(IJobList $jobList,
- IDBConnection $connection,
ILogger $logger) {
parent::__construct();
$this->jobList = $jobList;
- $this->connection = $connection;
$this->logger = $logger;
}
@@ -86,14 +80,7 @@ class Job extends Command {
$output->writeln('');
$output->writeln('<comment>Forcing execution of the job</comment>');
- $query = $this->connection->getQueryBuilder();
- $query->update('jobs')
- ->set('last_run', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
- ->set('reserved_at', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
- ->where($query->expr()->eq('id', $query->createNamedParameter($jobId), IQueryBuilder::PARAM_INT));
-
- $query->executeUpdate();
-
+ $this->jobList->resetBackgroundJob($job);
$job = $this->jobList->getById($jobId);
$job->execute($this->jobList, $this->logger);
$this->jobList->setLastJob($job);
@@ -110,15 +97,7 @@ class Job extends Command {
}
protected function printJobInfo(int $jobId, IJob $job, OutputInterface$output): void {
-
- $query = $this->connection->getQueryBuilder();
- $query->select('*')
- ->from('jobs')
- ->where($query->expr()->eq('id', $query->createNamedParameter($jobId), IQueryBuilder::PARAM_INT));
-
- $result = $query->executeQuery();
- $row = $result->fetch();
- $result->closeCursor();
+ $row = $this->jobList->getDetailsById($jobId);
$lastRun = new \DateTime();
$lastRun->setTimestamp((int) $row['last_run']);