diff --git a/src/MisuzuContext.php b/src/MisuzuContext.php index eadbf0d..e8f0c5c 100644 --- a/src/MisuzuContext.php +++ b/src/MisuzuContext.php @@ -43,7 +43,7 @@ class MisuzuContext { public function getDbQueryCount(): int { $result = $this->dbConn->query('SHOW SESSION STATUS LIKE "Questions"'); - return $result->next() ? $result->getInteger(0) : 0; + return $result->next() ? $result->getInteger(1) : 0; } public function createMigrationManager(): DbMigrationManager { diff --git a/src/TwigMisuzu.php b/src/TwigMisuzu.php index ce69db3..e38b6a6 100644 --- a/src/TwigMisuzu.php +++ b/src/TwigMisuzu.php @@ -38,12 +38,19 @@ final class TwigMisuzu extends AbstractExtension { new TwigFunction('git_tag', fn() => GitInfo::tag()), new TwigFunction('git_branch', fn() => GitInfo::branch()), new TwigFunction('startup_time', fn(float $time = MSZ_STARTUP) => microtime(true) - $time), - new TwigFunction('sql_query_count', fn() => DB::queries() + $this->ctx->getDbQueryCount()), + new TwigFunction('sql_query_count', fn() => $this->sqlQueryCount()), new TwigFunction('ndx_version', fn() => Environment::getIndexVersion()), new TwigFunction('byte_symbol', fn($bytes, $decimal = ByteFormat::DECIMAL_DEFAULT) => ByteFormat::format($bytes, $decimal)), ]; } + public function sqlQueryCount(): array { + $ndx = $this->ctx->getDbQueryCount(); + $pdo = DB::queries(); + $total = $ndx + $pdo; + return compact('ndx', 'pdo', 'total'); + } + public static $units = [ 'y' => 'year', 'm' => 'month', diff --git a/templates/_layout/footer.twig b/templates/_layout/footer.twig index d8c59fd..3da2316 100644 --- a/templates/_layout/footer.twig +++ b/templates/_layout/footer.twig @@ -14,8 +14,9 @@ {% endif %} # {{ git_commit_hash() }} {% if constant('MSZ_DEBUG') or current_user.super|default(false) %} + {% set sql_query_count = sql_query_count() %} / Index {{ ndx_version() }} - / SQL Queries: {{ sql_query_count()|number_format }} + / SQL Queries: {{ sql_query_count.total|number_format }} ({{ sql_query_count.ndx|number_format }} + {{ sql_query_count.pdo|number_format }}) / Took: {{ startup_time()|number_format(5) }} seconds / Load: {{ (startup_time() - startup_time(constant('MSZ_TPL_RENDER')))|number_format(5) }} seconds / Render: {{ startup_time(constant('MSZ_TPL_RENDER'))|number_format(5) }} seconds diff --git a/templates/home/landing.twig b/templates/home/landing.twig index cdf7c76..2f140ba 100644 --- a/templates/home/landing.twig +++ b/templates/home/landing.twig @@ -92,8 +92,9 @@ # {{ git_commit_hash() }} {% if constant('MSZ_DEBUG') or current_user.super|default(false) %} +{% set sql_query_count = sql_query_count() %} {% endif %}