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>
</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">
{!statusQuery.isLoading && statusQuery.data ? (
<>

View File

@@ -60,7 +60,8 @@ export const emailRouter = createTRPCRouter({
)
.query(async ({ ctx, input }) => {
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({
where: {
@@ -81,8 +82,12 @@ export const emailRouter = createTRPCRouter({
(acc, cur) => {
acc[cur.latestStatus] = {
count: (acc[cur.latestStatus]?.count || 0) + 1,
percentage:
(((acc[cur.latestStatus]?.count || 0) + 1) / totalCount) * 100,
percentage: Number(
(
(((acc[cur.latestStatus]?.count || 0) + 1) / totalCount) *
100
).toFixed(0)
),
};
return acc;
},