Hourly::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Analytics
4
 *
5
 * SPDX-FileCopyrightText: 2019-2022 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
Bug introduced by
The type OCP\AppFramework\Utility\ITimeFactory 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use OCP\BackgroundJob\TimedJob;
0 ignored issues
show
Bug introduced by
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

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
Bug introduced by
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

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 Hourly extends TimedJob
17
{
18
19
    private $logger;
20
    private $DataloadService;
21
22
    public function __construct(
23
        ITimeFactory $time,
24
        LoggerInterface $logger,
25
        DataloadService $DataloadService
26
    )
27
    {
28
        parent::__construct($time);
29
        $this->setInterval((60 * 60) - 120); // 2 minutes because exact times would drift to the next cron execution
30
        $this->logger = $logger;
31
        $this->DataloadService = $DataloadService;
32
    }
33
34
    public function run($arguments)
35
    {
36
        try {
37
            $this->DataloadService->executeBySchedule('h');
38
        } catch (\Exception $e) {
39
            // no action
40
        }
41
    }
42
43
}