Skip to content

Commit

Permalink
fixed DashboardImportance.php
Browse files Browse the repository at this point in the history
  • Loading branch information
tito10047 committed Sep 24, 2024
1 parent 277eb03 commit cebfa3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
->autoconfigure();
$services
->load('BugCatcher\\', '../src/')
->share()
->exclude('../src/{DependencyInjection,DataFixtures,Entity,DTO,Event,Factory,Extension,BugCatcherBundle.php}');

$services->set(PingCollectorCommand::class)->arg('$collectors',[
Expand Down
10 changes: 4 additions & 6 deletions src/Service/DashboardImportance.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ public function __construct(
) {}

public function upgradeHigher(string $group, Importance $importance, Notifier $notifier): void {
$current = $this->importance[$group]??[
"importance" => $importance,
"notifier" => $notifier,
];
$current = $this->importance[$group] ?? $this->load($group, $importance, $notifier);
if ($importance->isHigherThan($current["importance"])) {
$current = [
"importance" => $importance,
Expand All @@ -46,10 +43,11 @@ public function save(string $group): void {
}

#[ArrayShape(['importance' => "BugCatcher\Enum\Importance", 'notifier' => "BugCatcher\Entity\Notifier"])]
public function load(string $group): ?array {
public function load(string $group, $defaultImportance = null, $defaultNotifier = null): ?array
{
$group = substr(md5($group), 0, 8);
if (!file_exists($this->cacheDir . "/importance-$group.txt")) {
return ["importance" => null, "notifier" => null];
return ["importance" => $defaultImportance, "notifier" => $defaultNotifier];
}

return unserialize(file_get_contents($this->cacheDir . "/importance-$group.txt"));
Expand Down

0 comments on commit cebfa3c

Please sign in to comment.