( input: IReportInput )
| 82 | * Executes a simplified pipeline: normalize -> fetch aggregate -> format |
| 83 | */ |
| 84 | export async function executeAggregateChart( |
| 85 | input: IReportInput |
| 86 | ): Promise<FinalChart> { |
| 87 | // Stage 1: Normalize input |
| 88 | const normalized = await normalize(input); |
| 89 | |
| 90 | // Handle subscription end date limit |
| 91 | const endDate = await getOrganizationSubscriptionChartEndDate( |
| 92 | input.projectId, |
| 93 | normalized.endDate |
| 94 | ); |
| 95 | if (endDate) { |
| 96 | normalized.endDate = endDate; |
| 97 | } |
| 98 | |
| 99 | const { timezone } = await getSettingsForProject(normalized.projectId); |
| 100 | |
| 101 | // Stage 2: Fetch aggregate data for current period (event series only) |
| 102 | const fetchedSeries: ConcreteSeries[] = []; |
| 103 | |
| 104 | for (let i = 0; i < normalized.series.length; i++) { |
| 105 | const definition = normalized.series[i]!; |
| 106 | |
| 107 | if (definition.type !== 'event') { |
| 108 | // Skip formulas - they'll be computed in the next stage |
| 109 | continue; |
| 110 | } |
| 111 | |
| 112 | const event = definition as IChartEventItem & { type: 'event' }; |
| 113 | |
| 114 | // Build query input |
| 115 | const queryInput = { |
| 116 | event: { |
| 117 | id: event.id, |
| 118 | name: event.name, |
| 119 | segment: event.segment, |
| 120 | filters: event.filters, |
| 121 | displayName: event.displayName, |
| 122 | property: event.property, |
| 123 | }, |
| 124 | projectId: normalized.projectId, |
| 125 | startDate: normalized.startDate, |
| 126 | endDate: normalized.endDate, |
| 127 | breakdowns: normalized.breakdowns, |
| 128 | limit: normalized.limit, |
| 129 | metric: normalized.metric, |
| 130 | previous: normalized.previous, |
| 131 | timezone, |
| 132 | }; |
| 133 | |
| 134 | // Execute aggregate query |
| 135 | let queryResult = await chQuery<ISerieDataItem>( |
| 136 | await getAggregateChartSql(queryInput), |
| 137 | { |
| 138 | session_timezone: timezone, |
| 139 | } |
| 140 | ); |
| 141 |
nothing calls this directly
no test coverage detected