(
request: FastifyRequest<{
Querystring: z.infer<typeof chartSchemeFull>;
}>,
reply: FastifyReply
)
| 181 | }); |
| 182 | |
| 183 | export async function charts( |
| 184 | request: FastifyRequest<{ |
| 185 | Querystring: z.infer<typeof chartSchemeFull>; |
| 186 | }>, |
| 187 | reply: FastifyReply |
| 188 | ) { |
| 189 | const projectId = await getProjectId(request); |
| 190 | const { timezone } = await getSettingsForProject(projectId); |
| 191 | const { events, series, ...rest } = request.query; |
| 192 | |
| 193 | // Use series if available, otherwise fall back to events (backward compat) |
| 194 | const eventSeries = (series ?? events ?? []).map((event: any) => ({ |
| 195 | ...event, |
| 196 | type: event.type ?? 'event', |
| 197 | segment: event.segment ?? 'event', |
| 198 | filters: event.filters ?? [], |
| 199 | })); |
| 200 | |
| 201 | return ChartEngine.execute({ |
| 202 | ...rest, |
| 203 | startDate: rest.startDate |
| 204 | ? DateTime.fromISO(rest.startDate) |
| 205 | .setZone(timezone) |
| 206 | .toFormat('yyyy-MM-dd HH:mm:ss') |
| 207 | : undefined, |
| 208 | endDate: rest.endDate |
| 209 | ? DateTime.fromISO(rest.endDate) |
| 210 | .setZone(timezone) |
| 211 | .toFormat('yyyy-MM-dd HH:mm:ss') |
| 212 | : undefined, |
| 213 | projectId, |
| 214 | series: eventSeries, |
| 215 | chartType: 'linear', |
| 216 | metric: 'sum', |
| 217 | }); |
| 218 | } |
nothing calls this directly
no test coverage detected