Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| DocumentActivityCollector | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| metricIds | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| collect | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | /** |
| 5 | * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace OCA\Libresign\Service\UsageStatistics\Collector; |
| 10 | |
| 11 | use OCA\Libresign\Service\UsageStatistics\Contract\IMetricCollector; |
| 12 | use OCA\Libresign\Service\UsageStatistics\Model\MetricValue; |
| 13 | use OCA\Libresign\Service\UsageStatistics\Model\ReportMode; |
| 14 | use OCA\Libresign\Service\UsageStatistics\Model\ReportPeriod; |
| 15 | use OCA\Libresign\Service\UsageStatistics\Source\UsageActivityReader; |
| 16 | |
| 17 | /** |
| 18 | * Files are counted from the first install. Envelopes did not exist before |
| 19 | * LibreSign 12.2/13, so an earlier period has a known zero envelopes. |
| 20 | */ |
| 21 | class DocumentActivityCollector implements IMetricCollector { |
| 22 | public function __construct( |
| 23 | private UsageActivityReader $reader, |
| 24 | ) { |
| 25 | } |
| 26 | |
| 27 | #[\Override] |
| 28 | public function metricIds(): array { |
| 29 | return ['documents.files_created', 'documents.envelopes_created']; |
| 30 | } |
| 31 | |
| 32 | #[\Override] |
| 33 | public function collect(ReportPeriod $period, ReportMode $mode): array { |
| 34 | return [ |
| 35 | 'documents.files_created' => MetricValue::of($this->reader->countStandaloneFilesCreated($period)), |
| 36 | 'documents.envelopes_created' => MetricValue::of($this->reader->countEnvelopesCreated($period)), |
| 37 | ]; |
| 38 | } |
| 39 | } |