Rello /
analytics
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Analytics |
||
| 4 | * |
||
| 5 | * SPDX-FileCopyrightText: 2024 Marcel Scherello |
||
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace OCA\Analytics\BackgroundJob; |
||
| 10 | |||
| 11 | use OCA\Analytics\Service\DataloadService; |
||
| 12 | use OCP\AppFramework\Utility\ITimeFactory; |
||
|
0 ignored issues
–
show
|
|||
| 13 | use OCP\BackgroundJob\TimedJob; |
||
|
0 ignored issues
–
show
The type
OCP\BackgroundJob\TimedJob was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 14 | use Psr\Log\LoggerInterface; |
||
|
0 ignored issues
–
show
The type
Psr\Log\LoggerInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | |||
| 16 | class StartOfDay extends TimedJob |
||
| 17 | { |
||
| 18 | |||
| 19 | private $logger; |
||
| 20 | private $DataloadService; |
||
| 21 | |||
| 22 | public function __construct(ITimeFactory $time, |
||
| 23 | LoggerInterface $logger, |
||
| 24 | DataloadService $DataloadService |
||
| 25 | ) |
||
| 26 | { |
||
| 27 | parent::__construct($time); |
||
| 28 | $this->setInterval(60 * 10); // Check every 10 minutes to ensure it hits the 15 min window once |
||
| 29 | $this->logger = $logger; |
||
| 30 | $this->DataloadService = $DataloadService; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function run($arguments) |
||
| 34 | { |
||
| 35 | $currentTime = new \DateTime(); // Current time |
||
| 36 | $startOfDay = new \DateTime('today 00:00:00'); // Start of the day |
||
| 37 | $endOfFirst15Minutes = (clone $startOfDay)->modify('+15 minutes'); // End of first 15 minutes of the day |
||
| 38 | |||
| 39 | if ($currentTime >= $startOfDay && $currentTime <= $endOfFirst15Minutes) { |
||
| 40 | try { |
||
| 41 | $this->logger->debug('Analytics Dataload - Start of day'); |
||
| 42 | $this->DataloadService->executeBySchedule('s'); |
||
| 43 | } catch (\Exception $e) { |
||
| 44 | // Handle exception or log error |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths