Skip to content

Commit

Permalink
feat: optimize metrics query (nftstorage#1906)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
johnathonroach authored and gobengo committed Jun 14, 2022
1 parent 2a03744 commit 5c2c7f5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/api/src/utils/db-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5c2c7f5

Please sign in to comment.