From 4a9d7f714754e4019ee0e2b9a0a910ceb4ac4c1e Mon Sep 17 00:00:00 2001 From: Mark van Eijk Date: Mon, 16 Sep 2024 13:18:58 +0200 Subject: [PATCH] wip --- composer.json | 3 ++- src/Commands/StatusCommand.php | 39 +++++++--------------------------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/composer.json b/composer.json index 4ee732e..c0d5289 100644 --- a/composer.json +++ b/composer.json @@ -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" @@ -78,4 +79,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} \ No newline at end of file +} diff --git a/src/Commands/StatusCommand.php b/src/Commands/StatusCommand.php index 06dee12..d1008f8 100644 --- a/src/Commands/StatusCommand.php +++ b/src/Commands/StatusCommand.php @@ -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) { @@ -39,31 +39,21 @@ 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(); } @@ -71,22 +61,9 @@ public function handle() 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)); - } }