feat: api v1 garden bangs routes and openapi
This commit is contained in:
@@ -14,7 +14,10 @@ export type RecentBangDto = {
|
||||
recordedByName: string | null;
|
||||
};
|
||||
|
||||
export async function getBangStats(householdId: string, limit: number): Promise<BangStatsDto> {
|
||||
export async function getBangStatsForScope(
|
||||
householdId: string,
|
||||
limit: number,
|
||||
): Promise<BangStatsDto> {
|
||||
const [totalRow] = await db
|
||||
.select({ total: count() })
|
||||
.from(bangEvents)
|
||||
@@ -34,6 +37,14 @@ export async function getBangStats(householdId: string, limit: number): Promise<
|
||||
|
||||
return {
|
||||
total: totalRow?.total ?? 0,
|
||||
recent,
|
||||
recent: recent.map((r) => ({
|
||||
id: r.id,
|
||||
occurredOn: r.occurredOn,
|
||||
recordedByName: r.recordedByName,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export async function getBangStats(householdId: string, limit: number): Promise<BangStatsDto> {
|
||||
return getBangStatsForScope(householdId, limit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user