From 4445ad8fe5a9817008952ccbc99b5decd29abf59 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 9 Oct 2023 05:57:00 +0200 Subject: [PATCH] Expand debug info --- app/Http/Controllers/DebugController.php | 34 +++++++++++++++++------ resources/views/partials/debug-table.twig | 12 ++++++-- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index 5414311f8e..c4fc690fe1 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers; +use Carbon\Carbon; use DB; use Exception; -use FireflyConfig; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Middleware\IsDemoUser; use FireflyIII\Models\AccountType; @@ -229,8 +229,17 @@ class DebugController extends Controller { $userGuard = config('auth.defaults.guard'); + $config = app('fireflyconfig')->get('last_rt_job', 0); + $lastTime = (int)$config->data; + $lastCronjob = 'never'; + $lastCronjobAgo = 'never'; + if ($lastTime > 0) { + $carbon = Carbon::createFromTimestamp($lastTime); + $lastCronjob = $carbon->format('Y-m-d H:i:s'); + $lastCronjobAgo = $carbon->locale('en')->diffForHumans(); + } + return [ - 'tz' => env('TZ'), 'debug' => var_export(config('app.debug'), true), 'audit_log_channel' => envNonEmpty('AUDIT_LOG_CHANNEL', '(empty)'), 'default_language' => (string)config('firefly.default_language'), @@ -238,6 +247,13 @@ class DebugController extends Controller 'remote_header' => $userGuard === 'remote_user_guard' ? config('auth.guard_header') : 'N/A', 'remote_mail_header' => $userGuard === 'remote_user_guard' ? config('auth.guard_email') : 'N/A', 'stateful_domains' => join(', ', config('sanctum.stateful')), + + // the dates for the cron job are based on the recurring cron job's times. + // any of the cron jobs will do, they always run at the same time. + // but this job is the oldest, so the biggest chance it ran once + + 'last_cronjob' => $lastCronjob, + 'last_cronjob_ago' => $lastCronjobAgo, ]; } @@ -288,40 +304,40 @@ class DebugController extends Controller // has liabilities if ($user->accounts()->accountTypeIn([AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE])->count() > 0) { - $flags[] = ':credit_card:'; + $flags[] = ':credit_card:'; } // has piggies if ($user->piggyBanks()->count() > 0) { - $flags[] = ':pig:'; + $flags[] = ':pig:'; } // has stored reconciliations $type = TransactionType::whereType(TransactionType::RECONCILIATION)->first(); if ($user->transactionJournals()->where('transaction_type_id', $type->id)->count()) { - $flags[] = ':ledger:'; + $flags[] = ':ledger:'; } // has used importer? // has rules if ($user->rules()->count() > 0) { - $flags[] = ':wrench:'; + $flags[] = ':wrench:'; } // has recurring transactions if ($user->recurrences()->count() > 0) { - $flags[] = ':clock130:'; + $flags[] = ':clock130:'; } // has groups if ($user->objectGroups()->count() > 0) { - $flags[] = ':bookmark_tabs:'; + $flags[] = ':bookmark_tabs:'; } // uses bills if ($user->bills()->count() > 0) { - $flags[] = ':email:'; + $flags[] = ':email:'; } return join(' ', $flags); } diff --git a/resources/views/partials/debug-table.twig b/resources/views/partials/debug-table.twig index dcd3734842..243b40e354 100644 --- a/resources/views/partials/debug-table.twig +++ b/resources/views/partials/debug-table.twig @@ -64,12 +64,16 @@ Timezone - {{ app.timezone }} + [BrowserTZ] + {{ config('app.timezone') }} + [BrowserTZ] App environment {{ config('app.env') }}, debug: {{ app.debug }} + + Layout + {{ config('firefly.layout') }} + Logging {{ config('logging.level') }}, {{ config('logging.default') }} / {{ app.audit_log_channel }} @@ -98,6 +102,10 @@ Stateful domains {{ app.stateful_domains }} + + Last cron job + {{ app.last_cronjob }} ({{ app.last_cronjob_ago }}) + @@ -118,7 +126,7 @@ User flags - {{ user.user_flags }} + {{ user.user_flags | raw }} Session start