mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Breakdown report.
This commit is contained in:
parent
79ea9974b7
commit
e3cc19638c
21 changed files with 495 additions and 456 deletions
30
src/app/api/reports/breakdown/route.ts
Normal file
30
src/app/api/reports/breakdown/route.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { canViewWebsite } from '@/lib/auth';
|
||||
import { unauthorized, json } from '@/lib/response';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { getBreakdown } from '@/queries';
|
||||
import { reportResultSchema } from '@/lib/schema';
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const { auth, body, error } = await parseRequest(request, reportResultSchema);
|
||||
|
||||
if (error) {
|
||||
return error();
|
||||
}
|
||||
|
||||
const {
|
||||
websiteId,
|
||||
dateRange: { startDate, endDate },
|
||||
parameters: { fields },
|
||||
} = body;
|
||||
|
||||
if (!(await canViewWebsite(auth, websiteId))) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
const data = await getBreakdown(websiteId, fields, {
|
||||
startDate: new Date(startDate),
|
||||
endDate: new Date(endDate),
|
||||
});
|
||||
|
||||
return json(data);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue