Merge branch 'analytics' of https://github.com/umami-software/umami into analytics

This commit is contained in:
Francis Cao 2025-10-07 09:11:34 -07:00
commit 36ae53654d
2 changed files with 24 additions and 5 deletions

View file

@ -3,8 +3,27 @@ import { getRandomChars } from '@/lib/generate';
import { unauthorized, json } from '@/lib/response'; import { unauthorized, json } from '@/lib/response';
import { canCreateTeam } from '@/permissions'; import { canCreateTeam } from '@/permissions';
import { uuid } from '@/lib/crypto'; import { uuid } from '@/lib/crypto';
import { parseRequest } from '@/lib/request'; import { getQueryFilters, parseRequest } from '@/lib/request';
import { createTeam } from '@/queries/prisma'; 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) { export async function POST(request: Request) {
const schema = z.object({ const schema = z.object({

View file

@ -1,6 +1,6 @@
import { checkAuth } from '@/lib/auth'; import { checkAuth } from '@/lib/auth';
import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS } from '@/lib/constants'; 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 { fetchWebsite } from '@/lib/load';
import { filtersArrayToObject } from '@/lib/params'; import { filtersArrayToObject } from '@/lib/params';
import { badRequest, unauthorized } from '@/lib/response'; 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>) { export async function setWebsiteDate(websiteId: string, data: Record<string, any>) {
const website = await fetchWebsite(websiteId); const website = await fetchWebsite(websiteId);
if (website) { if (website?.resetAt) {
data.startDate = maxDate(data.startDate, new Date(website?.resetAt)); data.startDate = new Date(website.resetAt);
} }
return data; return data;