From 5c2c7f5ecc001adb18855cae6204211284b5bf2f Mon Sep 17 00:00:00 2001 From: Johnathon Roach Date: Tue, 7 Jun 2022 11:14:51 -0500 Subject: [PATCH] feat: optimize metrics query (#1906) This commit optimizes the metrics query to be less brittle in the case that the dimensions array data changes or takes on new values. Here, we query the presence of the keys instead of the exact match of the stringified array. --- packages/api/src/utils/db-client.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/api/src/utils/db-client.js b/packages/api/src/utils/db-client.js index 2c1e29970e..bdc0ca20d0 100644 --- a/packages/api/src/utils/db-client.js +++ b/packages/api/src/utils/db-client.js @@ -587,10 +587,8 @@ export class DBClient { const dagByteSizeQuery = metricsQuery .select('name, dimensions, value') - .match({ - name: 'dagcargo_project_bytes_in_active_deals', - dimensions: '{{project,nft.storage}}', - }) + .eq('name', 'dagcargo_project_bytes_in_active_deals') + .contains('dimensions', ['project', 'nft.storage']) .single() const weekAgo = new Date()