mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Merge branch 'analytics' of https://github.com/umami-software/umami into analytics
This commit is contained in:
commit
36ae53654d
2 changed files with 24 additions and 5 deletions
|
|
@ -3,8 +3,27 @@ import { getRandomChars } from '@/lib/generate';
|
|||
import { unauthorized, json } from '@/lib/response';
|
||||
import { canCreateTeam } from '@/permissions';
|
||||
import { uuid } from '@/lib/crypto';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { createTeam } from '@/queries/prisma';
|
||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||
import { createTeam, getUserTeams } from '@/queries/prisma';
|
||||
import { pagingParams } from '@/lib/schema';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const schema = z.object({
|
||||
...pagingParams,
|
||||
});
|
||||
|
||||
const { auth, query, error } = await parseRequest(request, schema);
|
||||
|
||||
if (error) {
|
||||
return error();
|
||||
}
|
||||
|
||||
const filters = await getQueryFilters(query);
|
||||
|
||||
const teams = await getUserTeams(auth.user.id, filters);
|
||||
|
||||
return json(teams);
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const schema = z.object({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { checkAuth } from '@/lib/auth';
|
||||
import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS } from '@/lib/constants';
|
||||
import { getAllowedUnits, getMinimumUnit, maxDate, parseDateRange } from '@/lib/date';
|
||||
import { getAllowedUnits, getMinimumUnit, parseDateRange } from '@/lib/date';
|
||||
import { fetchWebsite } from '@/lib/load';
|
||||
import { filtersArrayToObject } from '@/lib/params';
|
||||
import { badRequest, unauthorized } from '@/lib/response';
|
||||
|
|
@ -83,8 +83,8 @@ export function getRequestFilters(query: Record<string, any>) {
|
|||
export async function setWebsiteDate(websiteId: string, data: Record<string, any>) {
|
||||
const website = await fetchWebsite(websiteId);
|
||||
|
||||
if (website) {
|
||||
data.startDate = maxDate(data.startDate, new Date(website?.resetAt));
|
||||
if (website?.resetAt) {
|
||||
data.startDate = new Date(website.resetAt);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue