Update dashboard

This commit is contained in:
KMKoushik
2024-05-03 07:40:19 +10:00
parent 2d4babe618
commit 4e671556cc
2 changed files with 9 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ export default function DashboardChart() {
</Tabs> </Tabs>
</div> </div>
<div className="flex flex-col gap-8 mt-8"> <div className="flex flex-col gap-16 mt-10">
<div className="flex flex-wrap gap-2"> <div className="flex flex-wrap gap-2">
{!statusQuery.isLoading && statusQuery.data ? ( {!statusQuery.isLoading && statusQuery.data ? (
<> <>

View File

@@ -60,7 +60,8 @@ export const emailRouter = createTRPCRouter({
) )
.query(async ({ ctx, input }) => { .query(async ({ ctx, input }) => {
const { team } = ctx; const { team } = ctx;
const daysInMs = (input.days || 7) * 24 * 60 * 60 * 1000; const days = input.days !== 7 ? 30 : 7;
const daysInMs = days * 24 * 60 * 60 * 1000;
const rawEmailStatusCounts = await db.email.findMany({ const rawEmailStatusCounts = await db.email.findMany({
where: { where: {
@@ -81,8 +82,12 @@ export const emailRouter = createTRPCRouter({
(acc, cur) => { (acc, cur) => {
acc[cur.latestStatus] = { acc[cur.latestStatus] = {
count: (acc[cur.latestStatus]?.count || 0) + 1, count: (acc[cur.latestStatus]?.count || 0) + 1,
percentage: percentage: Number(
(((acc[cur.latestStatus]?.count || 0) + 1) / totalCount) * 100, (
(((acc[cur.latestStatus]?.count || 0) + 1) / totalCount) *
100
).toFixed(0)
),
}; };
return acc; return acc;
}, },