mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Fixed reports queries.
This commit is contained in:
parent
40970f6c33
commit
87bb9b1e73
5 changed files with 21 additions and 13 deletions
|
|
@ -4,7 +4,7 @@ import { NextApiRequestQueryBody, SearchFilter } from 'lib/types';
|
|||
import { pageInfo } from 'lib/schema';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok } from 'next-basics';
|
||||
import { createReport, getUserReports } from 'queries';
|
||||
import { createReport, getReports } from 'queries';
|
||||
import * as yup from 'yup';
|
||||
|
||||
export interface ReportsRequestQuery extends SearchFilter {}
|
||||
|
|
@ -50,13 +50,25 @@ export default async (
|
|||
} = req.auth;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { page, query, pageSize } = req.query;
|
||||
|
||||
const data = await getUserReports(userId, {
|
||||
const { page, query, pageSize, websiteId, teamId } = req.query;
|
||||
const filters = {
|
||||
page,
|
||||
pageSize: +pageSize || undefined,
|
||||
query,
|
||||
});
|
||||
};
|
||||
|
||||
const data = await getReports(
|
||||
{
|
||||
where: {
|
||||
userId: !(websiteId && teamId) ? userId : undefined,
|
||||
websiteId,
|
||||
},
|
||||
include: {
|
||||
website: true,
|
||||
},
|
||||
},
|
||||
filters,
|
||||
);
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue