mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/app/share/[...shareId]/Header.tsx
This commit is contained in:
commit
dfc6161a53
5 changed files with 23 additions and 19 deletions
|
|
@ -2,7 +2,7 @@ import { z } from 'zod';
|
|||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||
import { unauthorized, json } from '@/lib/response';
|
||||
import { canViewWebsite } from '@/permissions';
|
||||
import { pagingParams, timezoneParam } from '@/lib/schema';
|
||||
import { filterParams, pagingParams, timezoneParam } from '@/lib/schema';
|
||||
import { getWeeklyTraffic } from '@/queries';
|
||||
|
||||
export async function GET(
|
||||
|
|
@ -13,6 +13,7 @@ export async function GET(
|
|||
startAt: z.coerce.number().int(),
|
||||
endAt: z.coerce.number().int(),
|
||||
timezone: timezoneParam,
|
||||
...filterParams,
|
||||
...pagingParams,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export function PageviewsChart({ data, unit, minDate, maxDate, ...props }: Pagev
|
|||
__id: new Date().getTime(),
|
||||
datasets: [
|
||||
{
|
||||
type: data.compare ? 'line' : 'bar',
|
||||
type: 'bar',
|
||||
label: formatMessage(labels.visitors),
|
||||
data: generateTimeSeries(data.sessions, minDate, maxDate, unit, dateLocale),
|
||||
borderWidth: 1,
|
||||
|
|
@ -41,7 +41,7 @@ export function PageviewsChart({ data, unit, minDate, maxDate, ...props }: Pagev
|
|||
order: 3,
|
||||
},
|
||||
{
|
||||
type: data.compare ? 'line' : 'bar',
|
||||
type: 'bar',
|
||||
label: formatMessage(labels.views),
|
||||
data: generateTimeSeries(data.pageviews, minDate, maxDate, unit, dateLocale),
|
||||
barPercentage: 0.9,
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ export function formatDate(
|
|||
}
|
||||
|
||||
export function generateTimeSeries(
|
||||
data: { x: string; y: number }[],
|
||||
data: { x: string; y: number; d?: string }[],
|
||||
minDate: Date,
|
||||
maxDate: Date,
|
||||
unit: string,
|
||||
|
|
@ -345,12 +345,12 @@ export function generateTimeSeries(
|
|||
current = add(current, 1);
|
||||
}
|
||||
|
||||
const lookup = new Map(data.map(({ x, y }) => [formatDate(x, fmt, locale), { x, y }]));
|
||||
const lookup = new Map(data.map(({ x, y, d }) => [formatDate(x, fmt, locale), { x, y, d }]));
|
||||
|
||||
return timeseries.map(t => {
|
||||
const { x, y } = lookup.get(t) || {};
|
||||
const { x, y, d } = lookup.get(t) || {};
|
||||
|
||||
return { x: t, d: x, y: y ?? null };
|
||||
return { x: t, d: d ?? x, y: y ?? null };
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export async function deleteUser(
|
|||
|
||||
const teams = await client.team.findMany({
|
||||
where: {
|
||||
teamUser: {
|
||||
members: {
|
||||
some: {
|
||||
userId,
|
||||
role: ROLES.teamOwner,
|
||||
|
|
|
|||
|
|
@ -46,11 +46,16 @@ async function relationalQuery(
|
|||
return rawQuery(
|
||||
`
|
||||
WITH cohort_items AS (
|
||||
select session_id,
|
||||
${getDateSQL('created_at', unit)} as cohort_date
|
||||
from session
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
select
|
||||
min(${getDateSQL('website_event.created_at', unit, timezone)}) as cohort_date,
|
||||
website_event.session_id
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
${filterQuery}
|
||||
group by website_event.session_id
|
||||
),
|
||||
user_activities AS (
|
||||
select distinct
|
||||
|
|
@ -59,11 +64,9 @@ async function relationalQuery(
|
|||
from website_event
|
||||
join cohort_items
|
||||
on website_event.session_id = cohort_items.session_id
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
${filterQuery}
|
||||
|
||||
),
|
||||
cohort_size as (
|
||||
select cohort_date,
|
||||
|
|
@ -121,8 +124,10 @@ async function clickhouseQuery(
|
|||
min(${getDateSQL('created_at', unit, timezone)}) as cohort_date,
|
||||
session_id
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
${filterQuery}
|
||||
group by session_id
|
||||
),
|
||||
user_activities AS (
|
||||
|
|
@ -132,10 +137,8 @@ async function clickhouseQuery(
|
|||
from website_event
|
||||
join cohort_items
|
||||
on website_event.session_id = cohort_items.session_id
|
||||
${cohortQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
${filterQuery}
|
||||
),
|
||||
cohort_size as (
|
||||
select cohort_date,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue