Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Nov 26, 2021
1 parent 393d908 commit 03feecc
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/basic-usage/creating-custom-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@ class UsedDiskSpaceCheck extends Check
}
```

## Adding a label



4 changes: 4 additions & 0 deletions docs/viewing-results/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Viewing check results
weight: 3
---
4 changes: 4 additions & 0 deletions docs/viewing-results/as-json-via-an-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: As JSON via an API
weight: 3
---
4 changes: 4 additions & 0 deletions docs/viewing-results/on-a-webpage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: On a webpage
weight: 1
---
4 changes: 4 additions & 0 deletions docs/viewing-results/on-the-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: On the CLI
weight: 2
---
11 changes: 6 additions & 5 deletions resources/views/cli/list.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="m-1">
<div class="my-1">
@if(count($checkResults->storedCheckResults))
<div class="underline mb-1">Check results</div>
<div class="ml-1 underline mb-1">Check results</div>

<div class="mb-1">
Last ran all the checks {{ $lastRanAt->diffForHumans() }}
<div class="ml-1 mb-1">
Last ran all the checks {{ $lastRanAt->diffForHumans() }}.
</div>

<table style="box">
Expand All @@ -24,11 +24,12 @@
</tr>
@endforeach
</table>

@else
<div class="ml-1">
No checks have run yet...<br/>
Please execute:

php artisan health:run-checks
</div>
@endif
</div>
10 changes: 10 additions & 0 deletions src/Checks/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spatie\Health\Checks;

use Carbon\Carbon;
use Illuminate\Support\Str;
use Spatie\Health\Enums\Status;
use function trans;

Expand Down Expand Up @@ -32,6 +33,15 @@ public function shortSummary(string $shortSummary): self
return $this;
}

public function getShortSummary(): string
{
if (! empty($this->shortSummary)) {
return $this->shortSummary;
}

return Str::of($this->status)->snake()->replace('_', ' ')->title();
}

public function check(Check $check): self
{
$this->check = $check;
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/RunChecksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function runCheck(Check $check): Result
event(new CheckStartingEvent($check));

try {
$this->comment("Running check: {$check->getName()}");
$this->comment("Running check: {$check->getLabel()}");
$result = $check->run();
} catch (Exception $exception) {
$exception = CheckDidNotComplete::make($check, $exception);
Expand Down
2 changes: 1 addition & 1 deletion src/ResultStores/EloquentHealthResultStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function save(Collection $checkResults): void
'check_label' => $result->check->getLabel(),
'status' => $result->status,
'notification_message' => $result->getNotificationMessage(),
'short_summary' => $result->shortSummary,
'short_summary' => $result->getShortSummary(),
'meta' => $result->meta,
'batch' => $batch,
'ended_at' => $result->ended_at,
Expand Down
2 changes: 1 addition & 1 deletion src/ResultStores/JsonFileHealthResultStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function save(Collection $checkResults): void
name: $result->check->getName(),
label: $result->check->getLabel(),
notificationMessage: $result->getNotificationMessage(),
shortSummary: $result->shortSummary,
shortSummary: $result->getShortSummary(),
status: (string)$result->status->value,
meta: $result->meta,
);
Expand Down

0 comments on commit 03feecc

Please sign in to comment.