mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Add queries for new schema.
This commit is contained in:
parent
b0c7980a20
commit
5aa8187e42
25 changed files with 699 additions and 306 deletions
|
|
@ -52,8 +52,8 @@ export default async (
|
|||
const prevEndDate = new Date(+end_at - distance);
|
||||
|
||||
const metrics = await getWebsiteStats(websiteId, {
|
||||
start_at: startDate,
|
||||
end_at: endDate,
|
||||
startDate,
|
||||
endDate,
|
||||
filters: {
|
||||
url,
|
||||
referrer,
|
||||
|
|
@ -64,8 +64,8 @@ export default async (
|
|||
},
|
||||
});
|
||||
const prevPeriod = await getWebsiteStats(websiteId, {
|
||||
start_at: prevStartDate,
|
||||
end_at: prevEndDate,
|
||||
startDate: prevStartDate,
|
||||
endDate: prevEndDate,
|
||||
filters: {
|
||||
url,
|
||||
referrer,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { createWebsite, getAllWebsites, getUserWebsites } from 'queries';
|
||||
import { ok, methodNotAllowed, getRandomChars } from 'next-basics';
|
||||
import { useAuth, useCors } from 'lib/middleware';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { NextApiRequestQueryBody } from 'interface/api/nextApi';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { useAuth, useCors } from 'lib/middleware';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { getRandomChars, methodNotAllowed, ok } from 'next-basics';
|
||||
import { createWebsiteByUser, getAllWebsites, getWebsitesByUserId } from 'queries';
|
||||
|
||||
export interface WebsitesReqeustQuery {
|
||||
include_all?: boolean;
|
||||
|
|
@ -30,7 +30,7 @@ export default async (
|
|||
const { include_all } = req.query;
|
||||
|
||||
const websites =
|
||||
isAdmin && include_all ? await getAllWebsites() : await getUserWebsites(userId);
|
||||
isAdmin && include_all ? await getAllWebsites() : await getWebsitesByUserId(userId);
|
||||
|
||||
return ok(res, websites);
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ export default async (
|
|||
const { name, domain, enableShareUrl } = req.body;
|
||||
|
||||
const shareId = enableShareUrl ? getRandomChars(8) : null;
|
||||
const website = await createWebsite(userId, { id: uuid(), name, domain, shareId });
|
||||
const website = await createWebsiteByUser(userId, { id: uuid(), name, domain, shareId });
|
||||
|
||||
return ok(res, website);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue