From 5d852c1151ce17ed49f01d52d012d042431a0784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 19 Aug 2021 11:10:10 +0200 Subject: [PATCH] named counts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- plugins/catalog-backend/src/next/database/metrics.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/catalog-backend/src/next/database/metrics.ts b/plugins/catalog-backend/src/next/database/metrics.ts index f3e08287d8..a41ad512f0 100644 --- a/plugins/catalog-backend/src/next/database/metrics.ts +++ b/plugins/catalog-backend/src/next/database/metrics.ts @@ -52,16 +52,20 @@ export function initDatabaseMetrics(knex: Knex) { name: 'catalog_registered_locations_count', help: 'Total amount of registered locations in the catalog', async collect() { - const total = await knex('locations').count(); - this.set(total[0]['count(*)'] as number); + const total = await knex('locations').count({ + count: '*', + }); + this.set(Number(total[0].count)); }, }), relations: createGaugeMetric({ name: 'catalog_relations_count', help: 'Total amount of relations between entities', async collect() { - const total = await knex('relations').count(); - this.set(total[0]['count(*)'] as number); + const total = await knex('relations').count({ + count: '*', + }); + this.set(Number(total[0].count)); }, }), };