-
Notifications
You must be signed in to change notification settings - Fork 254
feat: Add charts API #811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2
Are you sure you want to change the base?
feat: Add charts API #811
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
||
// Convert first letter to lowercase to match common-utils expectations | ||
return metricType.charAt(0).toLowerCase() + metricType.slice(1); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will clean this up.
TL;DR zod schema uses MetricDataType from the clickhouse package which has values that are title cased. Everywhere else, we use MetricDataType from common-utils which has values that are lowercase.
'1d', | ||
'2d', | ||
'7d', | ||
'30d', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to use the keys from the record above to produce this list? it seems funny that it's the same set of strings in both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the only difference is that the test set allows 1 second of granularity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeahhhh def will clean that up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
packages/api/src/utils/zod.ts
Outdated
@@ -44,12 +43,15 @@ export const numberFormatSchema = z.object({ | |||
export const timeChartSeriesSchema = z.object({ | |||
table: z.optional(sourceTableSchema), | |||
type: z.literal('time'), | |||
aggFn: aggFnSchema, | |||
aggFn: AggregateFunctionSchema, | |||
level: z.number().optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it matters but level
represents a percentile value so it's more than just a number, it also needs to be between [0, 1]. Not sure if we want to try to bake that into the schema or not. I don't believe it is in common-utils either but doesn't seem like it holds up to user input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good callout ty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
packages/api/src/utils/zod.ts
Outdated
groupBy: z.array(z.string()).max(10), | ||
numberFormat: numberFormatSchema.optional(), | ||
metricDataType: z.optional(z.nativeEnum(MetricsDataType)), | ||
metricName: z.optional(z.string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this do something different that z.string().optional()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same difference. I'll make it consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
fe1f0bd
to
4529973
Compare
4529973
to
18b725a
Compare
Ref: HDX-1239
18b725a
to
64c8378
Compare
Testing Notes:
It was easiest for me to go to the UI, create a new chart and grab the sourceid and start/end timestamps from the URL, plug it in and profit.
Note: It was apparent to me that we will need to provide at least GET support for sources, otherwise that ID is not easily obtained.
Ref: HDX-1651