diff options
-rw-r--r-- | composer.json | 6 | ||||
-rw-r--r-- | composer.lock | 12 | ||||
-rw-r--r-- | lib/BackgroundJobs/MonthlyReport.php | 19 |
3 files changed, 20 insertions, 17 deletions
diff --git a/composer.json b/composer.json index 09b2826..7e14710 100644 --- a/composer.json +++ b/composer.json @@ -8,13 +8,11 @@ "name": "nextcloud/survey_client", "description": "Usage survey", "license": "AGPL", - "require": { - }, "require-dev": { "phpunit/phpunit": "^9.5", "nextcloud/coding-standard": "^1.0.0", - "christophwurst/nextcloud": "dev-master@dev", - "vimeo/psalm": "^4.3.2" + "vimeo/psalm": "^4.3.2", + "christophwurst/nextcloud": "dev-master" }, "config": { "optimize-autoloader": true, diff --git a/composer.lock b/composer.lock index 64e4f06..7943e85 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a302cab2d34495c261aafb5d120ad068", + "content-hash": "d3bd25437b13b0b1cde329a11d632070", "packages": [], "packages-dev": [ { @@ -179,12 +179,12 @@ "source": { "type": "git", "url": "https://github.com/ChristophWurst/nextcloud_composer.git", - "reference": "6aec9c3521c554466bb7d92559782cf61f391c79" + "reference": "b4818865f4ef2a23383dafdb44880216b9cf21aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ChristophWurst/nextcloud_composer/zipball/6aec9c3521c554466bb7d92559782cf61f391c79", - "reference": "6aec9c3521c554466bb7d92559782cf61f391c79", + "url": "https://api.github.com/repos/ChristophWurst/nextcloud_composer/zipball/b4818865f4ef2a23383dafdb44880216b9cf21aa", + "reference": "b4818865f4ef2a23383dafdb44880216b9cf21aa", "shasum": "" }, "require": { @@ -215,7 +215,7 @@ "issues": "https://github.com/ChristophWurst/nextcloud_composer/issues", "source": "https://github.com/ChristophWurst/nextcloud_composer/tree/master" }, - "time": "2022-02-07T08:09:24+00:00" + "time": "2022-04-08T01:48:24+00:00" }, { "name": "composer/package-versions-deprecated", @@ -4851,5 +4851,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } diff --git a/lib/BackgroundJobs/MonthlyReport.php b/lib/BackgroundJobs/MonthlyReport.php index 7f8620a..c427cc5 100644 --- a/lib/BackgroundJobs/MonthlyReport.php +++ b/lib/BackgroundJobs/MonthlyReport.php @@ -21,15 +21,23 @@ namespace OCA\Survey_Client\BackgroundJobs; -use OCA\Survey_Client\AppInfo\Application; +use OCA\Survey_Client\Collector; use OCP\AppFramework\Http; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\TimedJob; +use Psr\Log\LoggerInterface; class MonthlyReport extends TimedJob { - public function __construct(ITimeFactory $time) { + protected Collector $collector; + protected LoggerInterface $logger; + + public function __construct(ITimeFactory $time, + Collector $collector, + LoggerInterface $logger) { parent::__construct($time); + $this->collector = $collector; + $this->logger = $logger; // Run all 28 days $this->setInterval(28 * 24 * 60 * 60); // keeping time sensitive to not overload the target server at a single specific time of the day @@ -37,13 +45,10 @@ class MonthlyReport extends TimedJob { } protected function run($argument) { - $application = new Application(); - /** @var \OCA\Survey_Client\Collector $collector */ - $collector = $application->getContainer()->query('OCA\Survey_Client\Collector'); - $result = $collector->sendReport(); + $result = $this->collector->sendReport(); if ($result->getStatus() !== Http::STATUS_OK) { - \OC::$server->getLogger()->info('Error while sending usage statistic'); + $this->logger->info('Error while sending usage statistic'); } } } |