add in_progress hours

This commit is contained in:
Nathan 2026-02-05 16:14:04 -05:00
parent 78dd8cd78a
commit db7848214b
2 changed files with 28 additions and 7 deletions

View file

@ -33,7 +33,7 @@ admin.get('/stats', async ({ headers, status }) => {
return status(401, { error: 'Unauthorized' })
}
const [usersCount, projectsCount, totalHoursResult, pendingHoursResult] = await Promise.all([
const [usersCount, projectsCount, totalHoursResult, pendingHoursResult, inProgressHoursResult] = await Promise.all([
db.select({ count: sql<number>`count(*)` }).from(usersTable),
db.select({ count: sql<number>`count(*)` })
.from(projectsTable)
@ -49,6 +49,12 @@ admin.get('/stats', async ({ headers, status }) => {
.where(and(
eq(projectsTable.status, 'waiting_for_review'),
or(eq(projectsTable.deleted, 0), sql`${projectsTable.deleted} IS NULL`)
)),
db.select({ total: sql<number>`COALESCE(SUM(COALESCE(${projectsTable.hoursOverride}, ${projectsTable.hours})), 0)` })
.from(projectsTable)
.where(and(
eq(projectsTable.status, 'in_progress'),
or(eq(projectsTable.deleted, 0), sql`${projectsTable.deleted} IS NULL`)
))
])
@ -56,6 +62,7 @@ admin.get('/stats', async ({ headers, status }) => {
const totalProjects = Number(projectsCount[0]?.count || 0)
const totalHours = Number(totalHoursResult[0]?.total || 0)
const pendingHours = Number(pendingHoursResult[0]?.total || 0)
const inProgressHours = Number(inProgressHoursResult[0]?.total || 0)
const weightedGrants = Math.round(totalHours / 10 * 100) / 100
const pendingWeightedGrants = Math.round(pendingHours / 10 * 100) / 100
@ -65,7 +72,8 @@ admin.get('/stats', async ({ headers, status }) => {
totalHours: Math.round(totalHours * 10) / 10,
weightedGrants,
pendingHours: Math.round(pendingHours * 10) / 10,
pendingWeightedGrants
pendingWeightedGrants,
inProgressHours: Math.round(inProgressHours * 10) / 10
}
})

View file

@ -12,6 +12,7 @@
weightedGrants: number;
pendingHours: number;
pendingWeightedGrants: number;
inProgressHours: number;
}
let stats = $state<Stats | null>(null);
@ -100,20 +101,32 @@
<Hourglass size={32} />
</div>
<div>
<p class="text-sm font-bold text-gray-500">pending hours</p>
<p class="text-4xl font-bold text-yellow-600">{stats.pendingHours.toLocaleString()}h</p>
<p class="text-sm font-bold text-gray-500">in progress hours</p>
<p class="text-4xl font-bold text-yellow-600">{stats.inProgressHours.toLocaleString()}h</p>
</div>
</div>
<div class="flex items-center gap-4 rounded-2xl border-4 border-yellow-500 bg-yellow-50 p-6">
<div class="flex items-center gap-4 rounded-2xl border-4 border-blue-500 bg-blue-50 p-6">
<div
class="flex h-16 w-16 items-center justify-center rounded-full bg-yellow-500 text-white"
class="flex h-16 w-16 items-center justify-center rounded-full bg-blue-500 text-white"
>
<Hourglass size={32} />
</div>
<div>
<p class="text-sm font-bold text-gray-500">pending review hours</p>
<p class="text-4xl font-bold text-blue-600">{stats.pendingHours.toLocaleString()}h</p>
</div>
</div>
<div class="flex items-center gap-4 rounded-2xl border-4 border-blue-500 bg-blue-50 p-6">
<div
class="flex h-16 w-16 items-center justify-center rounded-full bg-blue-500 text-white"
>
<Scale size={32} />
</div>
<div>
<p class="text-sm font-bold text-gray-500">pending weighted grants</p>
<p class="text-4xl font-bold text-yellow-600">
<p class="text-4xl font-bold text-blue-600">
{stats.pendingWeightedGrants.toLocaleString()}
</p>
<p class="text-xs text-gray-400">pending hours ÷ 10</p>