fix(platform-service): missing cosmos containers + NaN guard in cross-product limit
- cosmos-init.ts: add onboarding_events + onboarding_completions containers (onboarding repository references them but they were never registered) - telemetry cross-product route: parseInt(limit) could produce NaN when given non-numeric input — now clamps to 1-100 with default 20
This commit is contained in:
parent
4e7401d164
commit
652a8e5d15
@ -147,6 +147,9 @@ const CONTAINER_DEFS: Record<string, ContainerConfig> = {
|
|||||||
diagnostic_insights: { partitionKeyPath: '/clusterId', defaultTtl: 90 * 86400 },
|
diagnostic_insights: { partitionKeyPath: '/clusterId', defaultTtl: 90 * 86400 },
|
||||||
diagnostic_queries: { partitionKeyPath: '/userId', defaultTtl: 30 * 86400 },
|
diagnostic_queries: { partitionKeyPath: '/userId', defaultTtl: 30 * 86400 },
|
||||||
proactive_alerts: { partitionKeyPath: '/productId', defaultTtl: 30 * 86400 },
|
proactive_alerts: { partitionKeyPath: '/productId', defaultTtl: 30 * 86400 },
|
||||||
|
// Onboarding analytics (Phase 4.3)
|
||||||
|
onboarding_events: { partitionKeyPath: '/productId' },
|
||||||
|
onboarding_completions: { partitionKeyPath: '/productId' },
|
||||||
// Broadcast Messaging & Surveys (see docs/roadmaps/not-started/platform_BROADCAST_SURVEY_ROADMAP.md)
|
// Broadcast Messaging & Surveys (see docs/roadmaps/not-started/platform_BROADCAST_SURVEY_ROADMAP.md)
|
||||||
broadcasts: { partitionKeyPath: '/productId' },
|
broadcasts: { partitionKeyPath: '/productId' },
|
||||||
broadcast_deliveries: { partitionKeyPath: '/userId', defaultTtl: 90 * 86400 },
|
broadcast_deliveries: { partitionKeyPath: '/userId', defaultTtl: 90 * 86400 },
|
||||||
|
|||||||
@ -928,10 +928,14 @@ export async function telemetryRoutes(app: FastifyInstance) {
|
|||||||
throw new BadRequestError('Provide 1-20 product IDs');
|
throw new BadRequestError('Provide 1-20 product IDs');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parsedLimit = limit ? parseInt(limit, 10) : 20;
|
||||||
|
const clampedLimit =
|
||||||
|
Number.isFinite(parsedLimit) && parsedLimit > 0 ? Math.min(parsedLimit, 100) : 20;
|
||||||
|
|
||||||
const [summary, daily, clusters] = await Promise.all([
|
const [summary, daily, clusters] = await Promise.all([
|
||||||
repo.queryCrossProductSummary(productIds, from, to),
|
repo.queryCrossProductSummary(productIds, from, to),
|
||||||
repo.queryCrossProductDaily(productIds, from, to),
|
repo.queryCrossProductDaily(productIds, from, to),
|
||||||
repo.queryCrossProductClusters(productIds, limit ? parseInt(limit, 10) : 20),
|
repo.queryCrossProductClusters(productIds, clampedLimit),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return { summary, daily, clusters };
|
return { summary, daily, clusters };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user