You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/webapp/app/presenters/OrgUsagePresenter.server.ts
+47-2Lines changed: 47 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ export class OrgUsagePresenter {
63
63
month: string;
64
64
count: number;
65
65
}[]
66
-
>`SELECT TO_CHAR("createdAt", 'YYYY-MM') as month, COUNT(*) as count FROM "JobRun" WHERE "organizationId" = ${organization.id} AND "createdAt" >= NOW() - INTERVAL '12 months' GROUP BY month ORDER BY month ASC`;
66
+
>`SELECT TO_CHAR("createdAt", 'YYYY-MM') as month, COUNT(*) as count FROM "JobRun" WHERE "organizationId" = ${organization.id} AND "createdAt" >= NOW() - INTERVAL '6 months' GROUP BY month ORDER BY month ASC`;
67
67
68
68
constchartData=chartDataRaw.map((obj)=>({
69
69
name: obj.month,
@@ -143,7 +143,7 @@ export class OrgUsagePresenter {
143
143
id: organization.id,
144
144
runsCount,
145
145
runsCountLastMonth,
146
-
chartData,
146
+
chartData: fillInMissingMonthlyData(chartData,6),
147
147
totalJobs,
148
148
totalJobsLastMonth,
149
149
totalIntegrations,
@@ -153,3 +153,48 @@ export class OrgUsagePresenter {
153
153
};
154
154
}
155
155
}
156
+
157
+
// This will fill in missing chart data with zeros
158
+
// So for example, if data is [{ name: "2021-01", total: 10 }, { name: "2021-03", total: 30 }] and the totalNumberOfMonths is 6
159
+
// And the current month is "2021-04", then this function will return:
0 commit comments