mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #1719 from appwrite/fix-accumulate-charts-with-trailing-zeros
fix: accumulate charts with trailing zeros
This commit is contained in:
@@ -41,10 +41,20 @@
|
||||
|
||||
export function accumulateFromEndingTotal(
|
||||
metrics: Models.Metric[],
|
||||
endingTotal: number
|
||||
endingTotal: number,
|
||||
startingDayToFillZero: Date = null
|
||||
): Array<[string, number]> {
|
||||
return (metrics ?? []).reduceRight(
|
||||
(acc, curr) => {
|
||||
if (startingDayToFillZero !== null && startingDayToFillZero instanceof Date) {
|
||||
const date = new Date(curr.date);
|
||||
if (date > startingDayToFillZero) {
|
||||
acc.data.unshift([date.toISOString(), 0]);
|
||||
acc.total -= 0;
|
||||
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
acc.data.unshift([curr.date, acc.total]);
|
||||
acc.total -= curr.value;
|
||||
return acc;
|
||||
|
||||
@@ -175,8 +175,9 @@
|
||||
{
|
||||
name: 'Users',
|
||||
data: accumulateFromEndingTotal(
|
||||
data.usersUsageToDate,
|
||||
data.organizationUsage.usersTotal
|
||||
data.organizationUsage.users,
|
||||
data.organizationUsage.usersTotal,
|
||||
new Date()
|
||||
)
|
||||
}
|
||||
]} />
|
||||
|
||||
@@ -78,15 +78,12 @@ export const load: PageLoad = async ({ params, parent }) => {
|
||||
}
|
||||
}
|
||||
|
||||
const usersUsageToDate = usage.users.filter((user) => new Date(user.date) < new Date());
|
||||
|
||||
return {
|
||||
organizationUsage: usage,
|
||||
projectNames,
|
||||
invoices,
|
||||
currentInvoice,
|
||||
organizationMembers,
|
||||
plan,
|
||||
usersUsageToDate
|
||||
plan
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user