mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +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 { getQueryFilters, parseRequest } from '@/lib/request';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
import { canViewWebsite } from '@/permissions';
|
import { canViewWebsite } from '@/permissions';
|
||||||
import { pagingParams, timezoneParam } from '@/lib/schema';
|
import { filterParams, pagingParams, timezoneParam } from '@/lib/schema';
|
||||||
import { getWeeklyTraffic } from '@/queries';
|
import { getWeeklyTraffic } from '@/queries';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
|
|
@ -13,6 +13,7 @@ export async function GET(
|
||||||
startAt: z.coerce.number().int(),
|
startAt: z.coerce.number().int(),
|
||||||
endAt: z.coerce.number().int(),
|
endAt: z.coerce.number().int(),
|
||||||
timezone: timezoneParam,
|
timezone: timezoneParam,
|
||||||
|
...filterParams,
|
||||||
...pagingParams,
|
...pagingParams,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ export function PageviewsChart({ data, unit, minDate, maxDate, ...props }: Pagev
|
||||||
__id: new Date().getTime(),
|
__id: new Date().getTime(),
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
type: data.compare ? 'line' : 'bar',
|
type: 'bar',
|
||||||
label: formatMessage(labels.visitors),
|
label: formatMessage(labels.visitors),
|
||||||
data: generateTimeSeries(data.sessions, minDate, maxDate, unit, dateLocale),
|
data: generateTimeSeries(data.sessions, minDate, maxDate, unit, dateLocale),
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
|
|
@ -41,7 +41,7 @@ export function PageviewsChart({ data, unit, minDate, maxDate, ...props }: Pagev
|
||||||
order: 3,
|
order: 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: data.compare ? 'line' : 'bar',
|
type: 'bar',
|
||||||
label: formatMessage(labels.views),
|
label: formatMessage(labels.views),
|
||||||
data: generateTimeSeries(data.pageviews, minDate, maxDate, unit, dateLocale),
|
data: generateTimeSeries(data.pageviews, minDate, maxDate, unit, dateLocale),
|
||||||
barPercentage: 0.9,
|
barPercentage: 0.9,
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ export function formatDate(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateTimeSeries(
|
export function generateTimeSeries(
|
||||||
data: { x: string; y: number }[],
|
data: { x: string; y: number; d?: string }[],
|
||||||
minDate: Date,
|
minDate: Date,
|
||||||
maxDate: Date,
|
maxDate: Date,
|
||||||
unit: string,
|
unit: string,
|
||||||
|
|
@ -345,12 +345,12 @@ export function generateTimeSeries(
|
||||||
current = add(current, 1);
|
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 => {
|
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({
|
const teams = await client.team.findMany({
|
||||||
where: {
|
where: {
|
||||||
teamUser: {
|
members: {
|
||||||
some: {
|
some: {
|
||||||
userId,
|
userId,
|
||||||
role: ROLES.teamOwner,
|
role: ROLES.teamOwner,
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,16 @@ async function relationalQuery(
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
WITH cohort_items AS (
|
WITH cohort_items AS (
|
||||||
select session_id,
|
select
|
||||||
${getDateSQL('created_at', unit)} as cohort_date
|
min(${getDateSQL('website_event.created_at', unit, timezone)}) as cohort_date,
|
||||||
from session
|
website_event.session_id
|
||||||
where website_id = {{websiteId::uuid}}
|
from website_event
|
||||||
and created_at between {{startDate}} and {{endDate}}
|
${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 (
|
user_activities AS (
|
||||||
select distinct
|
select distinct
|
||||||
|
|
@ -59,11 +64,9 @@ async function relationalQuery(
|
||||||
from website_event
|
from website_event
|
||||||
join cohort_items
|
join cohort_items
|
||||||
on website_event.session_id = cohort_items.session_id
|
on website_event.session_id = cohort_items.session_id
|
||||||
${cohortQuery}
|
|
||||||
${joinSessionQuery}
|
|
||||||
where website_id = {{websiteId::uuid}}
|
where website_id = {{websiteId::uuid}}
|
||||||
and created_at between {{startDate}} and {{endDate}}
|
and created_at between {{startDate}} and {{endDate}}
|
||||||
${filterQuery}
|
|
||||||
),
|
),
|
||||||
cohort_size as (
|
cohort_size as (
|
||||||
select cohort_date,
|
select cohort_date,
|
||||||
|
|
@ -121,8 +124,10 @@ async function clickhouseQuery(
|
||||||
min(${getDateSQL('created_at', unit, timezone)}) as cohort_date,
|
min(${getDateSQL('created_at', unit, timezone)}) as cohort_date,
|
||||||
session_id
|
session_id
|
||||||
from website_event
|
from website_event
|
||||||
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
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
|
group by session_id
|
||||||
),
|
),
|
||||||
user_activities AS (
|
user_activities AS (
|
||||||
|
|
@ -132,10 +137,8 @@ async function clickhouseQuery(
|
||||||
from website_event
|
from website_event
|
||||||
join cohort_items
|
join cohort_items
|
||||||
on website_event.session_id = cohort_items.session_id
|
on website_event.session_id = cohort_items.session_id
|
||||||
${cohortQuery}
|
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
${filterQuery}
|
|
||||||
),
|
),
|
||||||
cohort_size as (
|
cohort_size as (
|
||||||
select cohort_date,
|
select cohort_date,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue