Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| SigningActivityCollector | |
100.00% |
13 / 13 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| metricIds | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| collect | |
100.00% |
6 / 6 |
|
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 | * Rejection (LibreSign 15) and observers arrived together with the columns |
| 19 | * that record them, so before them the counts are a known zero. |
| 20 | */ |
| 21 | class SigningActivityCollector implements IMetricCollector { |
| 22 | public function __construct( |
| 23 | private UsageActivityReader $reader, |
| 24 | ) { |
| 25 | } |
| 26 | |
| 27 | #[\Override] |
| 28 | public function metricIds(): array { |
| 29 | return [ |
| 30 | 'signatures.requests_created', |
| 31 | 'signatures.completed', |
| 32 | 'signatures.rejected', |
| 33 | 'participants.observers_added', |
| 34 | ]; |
| 35 | } |
| 36 | |
| 37 | #[\Override] |
| 38 | public function collect(ReportPeriod $period, ReportMode $mode): array { |
| 39 | return [ |
| 40 | 'signatures.requests_created' => MetricValue::of($this->reader->countSigningRequestsCreated($period)), |
| 41 | 'signatures.completed' => MetricValue::of($this->reader->countSigningRequestsCompleted($period)), |
| 42 | 'signatures.rejected' => MetricValue::of($this->reader->countSigningRequestsRejected($period)), |
| 43 | 'participants.observers_added' => MetricValue::of($this->reader->countObserversAdded($period)), |
| 44 | ]; |
| 45 | } |
| 46 | } |