feat(api): explain dashboard chargeability by chapter
This commit is contained in:
@@ -65,6 +65,13 @@ export interface DashboardChargeabilityRow {
|
||||
derivation?: DashboardChargeabilityDerivation;
|
||||
}
|
||||
|
||||
export interface DashboardChargeabilityOverview {
|
||||
rows: DashboardChargeabilityRow[];
|
||||
top: DashboardChargeabilityRow[];
|
||||
watchlist: DashboardChargeabilityRow[];
|
||||
month: string;
|
||||
}
|
||||
|
||||
function toIsoDate(value: Date): string {
|
||||
return value.toISOString().slice(0, 10);
|
||||
}
|
||||
@@ -160,7 +167,7 @@ function summarizeDerivation(
|
||||
export async function getDashboardChargeabilityOverview(
|
||||
db: PrismaClient,
|
||||
input: GetDashboardChargeabilityOverviewInput,
|
||||
) {
|
||||
): Promise<DashboardChargeabilityOverview> {
|
||||
const now = input.now ?? new Date();
|
||||
const start = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
const end = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
||||
@@ -294,6 +301,7 @@ export async function getDashboardChargeabilityOverview(
|
||||
});
|
||||
|
||||
return {
|
||||
rows: stats,
|
||||
top: [...stats]
|
||||
.sort((left, right) => right.actualChargeability - left.actualChargeability),
|
||||
watchlist: [...stats]
|
||||
|
||||
Reference in New Issue
Block a user