MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / charts

Function charts

apps/api/src/controllers/export.controller.ts:183–218  ·  view source on GitHub ↗
(
  request: FastifyRequest<{
    Querystring: z.infer<typeof chartSchemeFull>;
  }>,
  reply: FastifyReply
)

Source from the content-addressed store, hash-verified

181 });
182
183export 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}

Callers

nothing calls this directly

Calls 4

getSettingsForProjectFunction · 0.90
executeMethod · 0.80
getProjectIdFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected