fix(dashboard): restrict data if trial ended

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-03-30 19:53:08 +02:00
parent ecda9a7d1b
commit 0f0bb13107
4 changed files with 40 additions and 15 deletions

View File

@@ -237,3 +237,22 @@ export const getOrganizationBillingEventsCountSerieCached = cacheable(
getOrganizationBillingEventsCountSerie,
60 * 10,
);
export async function getOrganizationSubscriptionChartEndDate(
projectId: string,
endDate: string,
) {
const organization = await getOrganizationByProjectIdCached(projectId);
if (!organization) {
return null;
}
// If the current period end date is after the subscription chart end date, we need to use the subscription chart end date
if (
organization.subscriptionChartEndDate &&
new Date(endDate) > organization.subscriptionChartEndDate
) {
return organization.subscriptionChartEndDate.toISOString();
}
return endDate;
}