From 20877aeed7730a81d08435be6bee1dfe6d9afebe Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Mon, 15 Nov 2021 19:36:25 +0000 Subject: [PATCH] fix: pin status metrics returns data object (#628) --- .../api/test/mocks/pgrest/post_rpc#pin_from_status_total.js | 4 +++- packages/db/postgres/metrics.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/api/test/mocks/pgrest/post_rpc#pin_from_status_total.js b/packages/api/test/mocks/pgrest/post_rpc#pin_from_status_total.js index 2422629698..b4f7a20416 100644 --- a/packages/api/test/mocks/pgrest/post_rpc#pin_from_status_total.js +++ b/packages/api/test/mocks/pgrest/post_rpc#pin_from_status_total.js @@ -4,6 +4,8 @@ module.exports = () => { return { statusCode: 200, - body: '30000' + body: [{ + pin_from_status_total: '30000' + }] } } diff --git a/packages/db/postgres/metrics.js b/packages/db/postgres/metrics.js index 2519006217..1862c3545b 100644 --- a/packages/db/postgres/metrics.js +++ b/packages/db/postgres/metrics.js @@ -76,13 +76,13 @@ const pinStatusMapping = { export async function getPinStatusMetrics (client, key) { const pinStatus = pinStatusMapping[key] - const { count, error } = await client.rpc('pin_from_status_total', { query_status: pinStatus }) + const { data, error } = await client.rpc('pin_from_status_total', { query_status: pinStatus }) if (error) { throw new DBError(error) } return { - total: count + total: data[0].pin_from_status_total } }