Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Sep 16, 2024
1 parent 4f0525f commit 4a9d7f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"illuminate/contracts": "^10.0|^11.0",
"lorisleiva/cron-translator": "^0.4.5",
"mtdowling/cron-expression": "^1.2",
"spatie/emoji": "^4.1",
"spatie/laravel-package-tools": "^1.14.0",
"symfony/dom-crawler": "^6.2",
"vlucas/phpdotenv": "^5.5"
Expand Down Expand Up @@ -78,4 +79,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
39 changes: 8 additions & 31 deletions src/Commands/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class StatusCommand extends Command
*/
public function handle()
{
$caches = OK::configuredChecks();
$checks = OK::configuredChecks();

$frequencies = collect(app(Schedule::class)->events())
->mapWithKeys(function ($schedule) {
Expand All @@ -39,54 +39,31 @@ public function handle()

$tableRows = [];

foreach ($caches as $c) {
$cache = $caches->current();
$parameters = $caches->getInfo();

foreach ($checks as $check) {
if (
$this->option('filter') &&
! str_contains(strtolower($cache->getName()), strtolower($this->option('filter')))
! str_contains(strtolower($check->getName()), strtolower($this->option('filter')))
) {
continue;
}

$cached = $cache->getMeta($parameters);

$row = [
$cache->isCached($parameters) ? Emoji::checkMarkButton() : Emoji::crossMark(),
$cache->getName(),
$cached ? readable_size(strlen(serialize($cached))) : 'N/A',
$cached?->updated_at?->diffForHumans() ?: 'N/A',
$frequencies[$cache->getName()] ?? 'N/A',
Emoji::checkMarkButton(),
$check->getName(),
// $check?->updated_at?->diffForHumans() ?: 'N/A',
$frequencies[$check->getName()] ?? 'N/A',
];

if ($this->option('parameters')) {
$row[] = $this->parseParameters($parameters);
}

$tableRows[] = $row;
$tableRows[] = new TableSeparator();
}

array_pop($tableRows);

$this->table(
[null, 'Cache', 'Size', 'Last Updated', 'Frequency'] + ($this->option('parameters') ? ['Parameters'] : []),
[null, 'Check', 'Last Updated', 'Frequency'],
$tableRows,
'box',
);
}

public function parseParameters($parameters)
{
$queryString = http_build_query($parameters);

return str_replace([
'=',
'&',
], [
': ',
', ',
], urldecode($queryString));
}
}

0 comments on commit 4a9d7f7

Please sign in to comment.