Skip to content

Commit 33b2b55

Browse files
authored
Remove arbitrary numeric keys from OxQL timeseries data (#2890)
* Remove arbitrary numeric keys from timeseries data * remove Object.values calls on timeseries data
1 parent 41ed7e3 commit 33b2b55

File tree

10 files changed

+82
-17
lines changed

10 files changed

+82
-17
lines changed

OMICRON_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19e9f75ba5fe26df6ac3ada2f3a3bb8fa032186c
1+
a9d9f1e1a17736aecc8d644c8d8c6174c1a5bc14

app/api/__generated__/Api.ts

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/OMICRON_VERSION

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/msw-handlers.ts

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/validate.ts

Lines changed: 21 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/window.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if (typeof window !== 'undefined') {
4747
const data = handleResult(result).tables
4848
logHeading(data.length + ' timeseries returned')
4949
for (const table of data) {
50-
for (const ts of Object.values(table.timeseries)) {
50+
for (const ts of table.timeseries) {
5151
const fields = Object.entries(ts.fields)
5252
.map(([k, v]) => `${k}: ${v.value}`)
5353
.join(', ')

app/components/oxql-metrics/util.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ const utilizationQueryResult1: OxqlQueryResult = {
131131
tables: [
132132
{
133133
name: 'virtual_machine:vcpu_usage',
134-
timeseries: {
135-
'16671618930358432507': {
134+
timeseries: [
135+
{
136136
fields: {
137137
vcpuId: {
138138
type: 'u32',
@@ -157,12 +157,12 @@ const utilizationQueryResult1: OxqlQueryResult = {
157157
],
158158
},
159159
},
160-
},
160+
],
161161
},
162162
],
163163
}
164164

165-
const timeseries1 = utilizationQueryResult1.tables[0].timeseries['16671618930358432507']
165+
const timeseries1 = utilizationQueryResult1.tables[0].timeseries[0]
166166

167167
test('sumValues', () => {
168168
expect(sumValues([], 0)).toEqual([])

app/components/oxql-metrics/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const sumValues = (timeseries: Timeseries[], arrLen: number): (number | n
129129
export const composeOxqlData = (data: OxqlQueryResult | undefined) => {
130130
let timeseriesCount = 0
131131
if (!data) return { chartData: [], timeseriesCount }
132-
const timeseriesData = Object.values(data.tables[0].timeseries)
132+
const timeseriesData = data.tables[0].timeseries
133133
timeseriesCount = timeseriesData.length
134134
if (!timeseriesCount) return { chartData: [], timeseriesCount }
135135
// Extract timestamps (all series should have the same timestamps)

mock-api/msw/handlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ export const handlers = makeHandlers({
16331633
// we use other-project to test certain response cases
16341634
if (query.project === 'other-project') {
16351635
// 1. return only one data point
1636-
const points = Object.values(data.tables[0].timeseries)[0].points
1636+
const points = data.tables[0].timeseries[0].points
16371637
if (body.query.includes('state == "run"')) {
16381638
points.timestamps = points.timestamps.slice(0, 2)
16391639
points.values = points.values.slice(0, 2)
@@ -1836,6 +1836,7 @@ export const handlers = makeHandlers({
18361836
networkingAddressLotCreate: NotImplemented,
18371837
networkingAddressLotDelete: NotImplemented,
18381838
networkingAddressLotList: NotImplemented,
1839+
networkingAddressLotView: NotImplemented,
18391840
networkingAllowListUpdate: NotImplemented,
18401841
networkingAllowListView: NotImplemented,
18411842
networkingBfdDisable: NotImplemented,

mock-api/oxql-metrics.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ export const getMockOxqlInstanceData = (
286286
tables: [
287287
{
288288
name: name,
289-
timeseries: {
289+
timeseries: [
290290
// This is a fake metric ID
291-
'10607783231231666598': {
291+
{
292292
fields: {
293293
instanceId: {
294294
type: 'uuid',
@@ -309,7 +309,7 @@ export const getMockOxqlInstanceData = (
309309
],
310310
},
311311
},
312-
},
312+
],
313313
},
314314
],
315315
})

0 commit comments

Comments
 (0)