Formatting data for Usage billing Daily usage charts

What does this MR do and why?

Adds data preparation phase to the daily usage. To accumulate credits used

This MR is the second in this MR chain:

title link
Initial structure Usage billing usage chart initial structure (!213057 - merged)
👉 Data accumulation in graphs Formatting data for Usage billing Daily usage c... (!214589)
UI polishes N/A

References

Screenshots or screen recordings

See comment below

How to set up and validate locally

  1. yarn storybook:start
  2. open http://localhost:6006/?path=/story/ee-usage-quotas-usage-billing-app--default

Note: to reproduce current month view in Storybook, we'll need to update mocks with the following patch:

diff
diff --git a/ee/spec/frontend/usage_quotas/usage_billing/components/usage_trends_chart_spec.js b/ee/spec/frontend/usage_quotas/usage_billing/components/usage_trends_chart_spec.js
index 77e9bb5fee392..58ee1d375b4e3 100644
--- a/ee/spec/frontend/usage_quotas/usage_billing/components/usage_trends_chart_spec.js
+++ b/ee/spec/frontend/usage_quotas/usage_billing/components/usage_trends_chart_spec.js
@@ -23,7 +23,7 @@ describe('UsageTrendsChart', () => {
 
         // Set a fake date, as we use today date for data manipulation
         // 20th Oct 2025
-        useFakeDate(2025, 9, 20);
+        useFakeDate(2025, 9, 20, 23, 55, 0);
 
         const defaultProps = {
           monthStartDate: '2025-10-01',
diff --git a/ee/spec/frontend/usage_quotas/usage_billing/mock_data.js b/ee/spec/frontend/usage_quotas/usage_billing/mock_data.js
index 4fb91041a685c..0c38b33dbaf03 100644
--- a/ee/spec/frontend/usage_quotas/usage_billing/mock_data.js
+++ b/ee/spec/frontend/usage_quotas/usage_billing/mock_data.js
@@ -104,7 +104,7 @@ export const mockUsersUsageDataWithPool = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
       purchaseCreditsPath: '/purchase-credits-path',
@@ -240,7 +240,7 @@ export const mockUsersUsageDataWithOverage = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
       purchaseCreditsPath: '/purchase-credits-path',
@@ -374,12 +374,12 @@ export const mockUsersUsageDataWithZeroAllocation = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
       purchaseCreditsPath: '/purchase-credits-path',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
 
       usersUsage: {
         totalUsers: 5,
@@ -655,20 +655,20 @@ export const usageDataWithCommitment = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
-      startDate: '2025-10-01',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
+      startDate: '2025-12-01',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      endDate: '2025-10-31',
+      endDate: '2025-12-31',
       purchaseCreditsPath: '/purchase-credits-path',
       monthlyCommitment: {
         creditsUsed: 50.333,
         totalCredits: 100,
         dailyUsage: [
-          { creditsUsed: 5, date: '2025-10-06' },
-          { creditsUsed: 12, date: '2025-10-07' },
-          { creditsUsed: 18, date: '2025-10-10' },
-          { creditsUsed: 15.333, date: '2025-10-11' },
+          { creditsUsed: 5, date: '2025-12-06' },
+          { creditsUsed: 12, date: '2025-12-07' },
+          { creditsUsed: 18, date: '2025-12-10' },
+          { creditsUsed: 15.333, date: '2025-12-11' },
         ],
       },
       overage: {
@@ -694,8 +694,8 @@ export const usageDataWithoutLastEventTransactionAt = {
       lastEventTransactionAt: null,
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       purchaseCreditsPath: '/purchase-credits-path',
 
       monthlyCommitment: null,
@@ -710,31 +710,31 @@ export const usageDataWithCommitmentWithMonthlyWaiver = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       purchaseCreditsPath: '/purchase-credits-path',
 
       monthlyCommitment: {
         creditsUsed: 50,
         totalCredits: 50,
         dailyUsage: [
-          { creditsUsed: 5, date: '2025-10-06' },
-          { creditsUsed: 12, date: '2025-10-07' },
-          { creditsUsed: 18, date: '2025-10-10' },
-          { creditsUsed: 15, date: '2025-10-11' },
+          { creditsUsed: 5, date: '2025-12-06' },
+          { creditsUsed: 12, date: '2025-12-07' },
+          { creditsUsed: 18, date: '2025-12-10' },
+          { creditsUsed: 15, date: '2025-12-11' },
         ],
       },
       monthlyWaiver: {
         creditsUsed: 50.125,
         totalCredits: 100,
         dailyUsage: [
-          { creditsUsed: 8.5, date: '2025-10-11' },
-          { creditsUsed: 12.25, date: '2025-10-12' },
-          { creditsUsed: 15.375, date: '2025-10-13' },
-          { creditsUsed: 14, date: '2025-10-14' },
+          { creditsUsed: 8.5, date: '2025-12-11' },
+          { creditsUsed: 12.25, date: '2025-12-12' },
+          { creditsUsed: 15.375, date: '2025-12-13' },
+          { creditsUsed: 14, date: '2025-12-14' },
         ],
       },
       overage: {
@@ -750,31 +750,31 @@ export const usageDataWithCommitmentWithOverage = {
   data: {
     subscriptionUsage: {
       purchaseCreditsPath: '/purchase-credits-path',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
       monthlyCommitment: {
         creditsUsed: 50,
         totalCredits: 50,
         dailyUsage: [
-          { creditsUsed: 5, date: '2025-10-06' },
-          { creditsUsed: 12, date: '2025-10-07' },
-          { creditsUsed: 18, date: '2025-10-10' },
-          { creditsUsed: 15, date: '2025-10-11' },
+          { creditsUsed: 5, date: '2025-12-06' },
+          { creditsUsed: 12, date: '2025-12-07' },
+          { creditsUsed: 18, date: '2025-12-10' },
+          { creditsUsed: 15, date: '2025-12-11' },
         ],
       },
       overage: {
         isAllowed: true,
         creditsUsed: 50,
         dailyUsage: [
-          { creditsUsed: 8.5, date: '2025-10-11' },
-          { creditsUsed: 12.25, date: '2025-10-12' },
-          { creditsUsed: 15.75, date: '2025-10-13' },
-          { creditsUsed: 13.5, date: '2025-10-14' },
+          { creditsUsed: 8.5, date: '2025-12-11' },
+          { creditsUsed: 12.25, date: '2025-12-12' },
+          { creditsUsed: 15.75, date: '2025-12-13' },
+          { creditsUsed: 13.5, date: '2025-12-14' },
         ],
       },
 
@@ -795,8 +795,8 @@ export const usageDataNoCommitmentNoMonthlyWaiverNoOverage = {
       lastEventTransactionAt: '2024-01-15T10:30:00Z',
       canAcceptOverageTerms: true,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       purchaseCreditsPath: '/purchase-credits-path',
       monthlyCommitment: null,
       overage: {
@@ -819,22 +819,22 @@ export const usageDataNoCommitmentWithOverage = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       purchaseCreditsPath: '/purchase-credits-path',
       monthlyCommitment: null,
       overage: {
         isAllowed: true,
         creditsUsed: 50,
         dailyUsage: [
-          { creditsUsed: 10.5, date: '2025-10-01' },
-          { creditsUsed: 8.75, date: '2025-10-02' },
-          { creditsUsed: 12.25, date: '2025-10-03' },
-          { creditsUsed: 9.5, date: '2025-10-04' },
-          { creditsUsed: 9, date: '2025-10-05' },
+          { creditsUsed: 10.5, date: '2025-12-01' },
+          { creditsUsed: 8.75, date: '2025-12-02' },
+          { creditsUsed: 12.25, date: '2025-12-03' },
+          { creditsUsed: 9.5, date: '2025-12-04' },
+          { creditsUsed: 9, date: '2025-12-05' },
         ],
       },
 
@@ -862,22 +862,22 @@ export const usageDataCommitmentWithMonthlyWaiver = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       purchaseCreditsPath: '/purchase-credits-path',
 
       monthlyCommitment: {
         creditsUsed: 50,
         totalCredits: 50,
         dailyUsage: [
-          { creditsUsed: 8, date: '2025-10-01' },
-          { creditsUsed: 12, date: '2025-10-02' },
-          { creditsUsed: 10, date: '2025-10-03' },
-          { creditsUsed: 15, date: '2025-10-04' },
-          { creditsUsed: 5, date: '2025-10-05' },
+          { creditsUsed: 8, date: '2025-12-01' },
+          { creditsUsed: 12, date: '2025-12-02' },
+          { creditsUsed: 10, date: '2025-12-03' },
+          { creditsUsed: 15, date: '2025-12-04' },
+          { creditsUsed: 5, date: '2025-12-05' },
         ],
       },
 
@@ -891,11 +891,11 @@ export const usageDataCommitmentWithMonthlyWaiver = {
         totalCredits: 100,
         creditsUsed: 75,
         dailyUsage: [
-          { creditsUsed: 12.5, date: '2025-10-06' },
-          { creditsUsed: 15.25, date: '2025-10-07' },
-          { creditsUsed: 18.75, date: '2025-10-08' },
-          { creditsUsed: 14.5, date: '2025-10-09' },
-          { creditsUsed: 14, date: '2025-10-10' },
+          { creditsUsed: 12.5, date: '2025-12-06' },
+          { creditsUsed: 15.25, date: '2025-12-07' },
+          { creditsUsed: 18.75, date: '2025-12-08' },
+          { creditsUsed: 14.5, date: '2025-12-09' },
+          { creditsUsed: 14, date: '2025-12-10' },
         ],
       },
     },
@@ -907,22 +907,22 @@ export const usageDataCommitmentWithMonthlyWaiverWithOverage = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       purchaseCreditsPath: '/purchase-credits-path',
 
       monthlyCommitment: {
         creditsUsed: 100,
         totalCredits: 100,
         dailyUsage: [
-          { creditsUsed: 18, date: '2025-10-01' },
-          { creditsUsed: 22, date: '2025-10-02' },
-          { creditsUsed: 20, date: '2025-10-03' },
-          { creditsUsed: 25, date: '2025-10-04' },
-          { creditsUsed: 15, date: '2025-10-05' },
+          { creditsUsed: 18, date: '2025-12-01' },
+          { creditsUsed: 22, date: '2025-12-02' },
+          { creditsUsed: 20, date: '2025-12-03' },
+          { creditsUsed: 25, date: '2025-12-04' },
+          { creditsUsed: 15, date: '2025-12-05' },
         ],
       },
 
@@ -930,10 +930,10 @@ export const usageDataCommitmentWithMonthlyWaiverWithOverage = {
         isAllowed: true,
         creditsUsed: 24,
         dailyUsage: [
-          { creditsUsed: 4.5, date: '2025-10-11' },
-          { creditsUsed: 6.25, date: '2025-10-12' },
-          { creditsUsed: 7.75, date: '2025-10-13' },
-          { creditsUsed: 5.5, date: '2025-10-14' },
+          { creditsUsed: 4.5, date: '2025-12-11' },
+          { creditsUsed: 6.25, date: '2025-12-12' },
+          { creditsUsed: 7.75, date: '2025-12-13' },
+          { creditsUsed: 5.5, date: '2025-12-14' },
         ],
       },
 
@@ -941,11 +941,11 @@ export const usageDataCommitmentWithMonthlyWaiverWithOverage = {
         totalCredits: 100,
         creditsUsed: 100,
         dailyUsage: [
-          { creditsUsed: 16.5, date: '2025-10-06' },
-          { creditsUsed: 22.25, date: '2025-10-07' },
-          { creditsUsed: 28.125, date: '2025-10-08' },
-          { creditsUsed: 21.125, date: '2025-10-09' },
-          { creditsUsed: 12, date: '2025-10-10' },
+          { creditsUsed: 16.5, date: '2025-12-06' },
+          { creditsUsed: 22.25, date: '2025-12-07' },
+          { creditsUsed: 28.125, date: '2025-12-08' },
+          { creditsUsed: 21.125, date: '2025-12-09' },
+          { creditsUsed: 12, date: '2025-12-10' },
         ],
       },
     },
@@ -957,11 +957,11 @@ export const usageDataWithOutdatedClient = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: true,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       purchaseCreditsPath: '/purchase-credits-path',
       monthlyCommitment: null,
       monthlyWaiver: null,
@@ -993,11 +993,11 @@ export const usageDataWithoutPurchaseCreditsPath = {
     subscriptionUsage: {
       enabled: true,
       isOutdatedClient: false,
-      lastEventTransactionAt: '2025-10-14T07:41:59Z',
+      lastEventTransactionAt: '2025-12-14T07:41:59Z',
       canAcceptOverageTerms: false,
       subscriptionPortalUsageDashboardUrl: 'https://customers.gitlab.com',
-      startDate: '2025-10-01',
-      endDate: '2025-10-31',
+      startDate: '2025-12-01',
+      endDate: '2025-12-31',
       purchaseCreditsPath: null,
       monthlyCommitment: null,
       monthlyWaiver: null,

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kos Palchyk

Merge request reports

Loading