Refresh demo route snapshots
Build and deploy Docker image / build (push) Successful in 43s

This commit is contained in:
Ruslan Bakiev
2026-08-24 21:50:38 +07:00
parent f1ecd83e9c
commit 1811820fb7
+22 -5
View File
@@ -169,8 +169,10 @@ export async function ensureDemoWorkspaceData(access: DemoWorkspaceAccess): Prom
orderCount,
demoQuotationPricingCount,
demoOrderPricingCount,
demoQuotationWithoutRouteCount,
demoOrderWithoutRouteCount,
demoQuotationCount,
demoOrderCount,
demoQuotationRouteStageCount,
demoOrderRouteStageCount,
] = await Promise.all([
prisma.quotation.count({ where: { teamUuid: access.teamUuid } }),
prisma.order.count({ where: { teamUuid: access.teamUuid } }),
@@ -181,16 +183,31 @@ export async function ensureDemoWorkspaceData(access: DemoWorkspaceAccess): Prom
where: { teamUuid: access.teamUuid, notes: demoNote, sourceAmount: null },
}),
prisma.quotation.count({
where: { teamUuid: access.teamUuid, notes: demoNote, routeStages: { none: {} } },
where: { teamUuid: access.teamUuid, notes: demoNote },
}),
prisma.order.count({
where: { teamUuid: access.teamUuid, notes: demoNote, routeStages: { none: {} } },
where: { teamUuid: access.teamUuid, notes: demoNote },
}),
prisma.quotationRouteStage.count({
where: { quotation: { teamUuid: access.teamUuid, notes: demoNote } },
}),
prisma.orderRouteStage.count({
where: { order: { teamUuid: access.teamUuid, notes: demoNote } },
}),
])
const needsCalculations = quotationCount === 0
const needsOrders = orderCount === 0
const needsPricingBackfill = demoQuotationPricingCount > 0 || demoOrderPricingCount > 0
const needsRouteBackfill = demoQuotationWithoutRouteCount > 0 || demoOrderWithoutRouteCount > 0
const expectedQuotationRouteStageCount = demoRoutes.reduce(
(total, route) => total + route.stages.length,
0,
)
const expectedOrderRouteStageCount = demoRoutes
.slice(0, 2)
.reduce((total, route) => total + route.stages.length, 0)
const needsRouteBackfill =
(demoQuotationCount > 0 && demoQuotationRouteStageCount < expectedQuotationRouteStageCount) ||
(demoOrderCount > 0 && demoOrderRouteStageCount < expectedOrderRouteStageCount)
const kyc = needsCalculations || needsOrders || needsPricingBackfill || needsRouteBackfill
? await ensureDemoKycPricingContext({
teamUuid: access.teamUuid,