ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDatabaseUpdateStepsMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
27{
28 public const STEP_METHOD_PREFIX = "step_";
29
30 protected string $step_class;
31
33 {
35 $this->step_class = $steps::class;
36 }
37
38 protected function collectFrom(Environment $environment, Storage $storage): void
39 {
40 $execution_log = $environment->getResource(ilDatabaseUpdateStepExecutionLog::class);
41 $step_reader = $environment->getResource(ilDBStepReader::class);
42
43 $version = new Metric(
44 Metric::STABILITY_STABLE,
45 Metric::TYPE_TEXT,
46 (string) ($execution_log->getLastFinishedStep($this->step_class))
47 );
48
49 $available_version = new Metric(
50 Metric::STABILITY_STABLE,
51 Metric::TYPE_TEXT,
52 (string) $step_reader->getLatestStepNumber($this->step_class, self::STEP_METHOD_PREFIX)
53 );
54
55 $update_required = new Metric(
56 Metric::STABILITY_STABLE,
57 Metric::TYPE_BOOL,
58 $execution_log->getLastFinishedStep($this->step_class) !== $step_reader->getLatestStepNumber(
59 $this->step_class,
60 self::STEP_METHOD_PREFIX
61 )
62 );
63
64 $collection = new Metric(
65 Metric::STABILITY_STABLE,
66 Metric::TYPE_COLLECTION,
67 [
68 "version" => $version,
69 "available_version" => $available_version,
70 "update_required" => $update_required
71 ]
72 );
73
74 $storage->store($this->step_class, $collection);
75 }
76
77 protected function getTentativePreconditions(Environment $environment): array
78 {
79 return [
83 ];
84 }
85
86 #[\Override]
87 public function getHash(): string
88 {
89 return hash("sha256", static::class . $this->step_class);
90 }
91
92 #[\Override]
93 public function getLabel(): string
94 {
95 return "Status of database update steps in " . $this->step_class;
96 }
97}
$version
Definition: plugin.php:24
Base class to simplify collection of metrics.
A metric is something we can measure about the system.
Definition: Metric.php:34
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
store(string $key, Metric $metric)
Store some metric in the storage.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc