mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-05 17:05:46 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
1341f449a8
@ -36,7 +36,7 @@ export function BarChart(props: BarChartProps) {
|
||||
x: {
|
||||
type: XAxisType,
|
||||
stacked: true,
|
||||
min: minDate,
|
||||
min: unit === 'minute' ? minDate : '',
|
||||
max: maxDate,
|
||||
time: {
|
||||
unit,
|
||||
|
@ -63,9 +63,9 @@ function getDateStringSQL(data: any, unit: string = 'utc', timezone?: string) {
|
||||
|
||||
function getDateSQL(field: string, unit: string, timezone?: string) {
|
||||
if (timezone) {
|
||||
return `date_trunc('${unit}', ${field}, '${timezone}')`;
|
||||
return `toDateTime(date_trunc('${unit}', ${field}, '${timezone}'), '${timezone}')`;
|
||||
}
|
||||
return `date_trunc('${unit}', ${field})`;
|
||||
return `toDateTime(date_trunc('${unit}', ${field}))`;
|
||||
}
|
||||
|
||||
function mapFilter(column: string, operator: string, name: string, type: string = 'String') {
|
||||
|
@ -41,8 +41,8 @@ async function clickhouseQuery(
|
||||
websiteId: string,
|
||||
filters: QueryFilters,
|
||||
): Promise<{ x: string; y: number }[]> {
|
||||
const { unit = 'day' } = filters;
|
||||
const { parseFilters, rawQuery } = clickhouse;
|
||||
const { timezone = 'utc', unit = 'day' } = filters;
|
||||
const { parseFilters, rawQuery, getDateSQL } = clickhouse;
|
||||
const { filterQuery, params } = await parseFilters(websiteId, {
|
||||
...filters,
|
||||
eventType: EVENT_TYPE.pageView,
|
||||
@ -57,7 +57,7 @@ async function clickhouseQuery(
|
||||
g.y as y
|
||||
from (
|
||||
select
|
||||
date_trunc('${unit}', created_at) as t,
|
||||
${getDateSQL('website_event.created_at', unit, timezone)} as t,
|
||||
count(*) as y
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
@ -75,7 +75,7 @@ async function clickhouseQuery(
|
||||
g.y as y
|
||||
from (
|
||||
select
|
||||
date_trunc('${unit}', created_at) as t,
|
||||
${getDateSQL('website_event.created_at', unit, timezone)} as t,
|
||||
sum(views)as y
|
||||
from website_event_stats_hourly website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
|
@ -41,8 +41,8 @@ async function clickhouseQuery(
|
||||
websiteId: string,
|
||||
filters: QueryFilters,
|
||||
): Promise<{ x: string; y: number }[]> {
|
||||
const { unit = 'day' } = filters;
|
||||
const { parseFilters, rawQuery } = clickhouse;
|
||||
const { timezone = 'utc', unit = 'day' } = filters;
|
||||
const { parseFilters, rawQuery, getDateSQL } = clickhouse;
|
||||
const { filterQuery, params } = await parseFilters(websiteId, {
|
||||
...filters,
|
||||
eventType: EVENT_TYPE.pageView,
|
||||
@ -53,11 +53,11 @@ async function clickhouseQuery(
|
||||
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item)) || unit === 'minute') {
|
||||
sql = `
|
||||
select
|
||||
g.t as x,
|
||||
g.t as x,
|
||||
g.y as y
|
||||
from (
|
||||
select
|
||||
date_trunc('${unit}', created_at) as t,
|
||||
${getDateSQL('website_event.created_at', unit, timezone)} as t,
|
||||
count(distinct session_id) as y
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
@ -71,11 +71,11 @@ async function clickhouseQuery(
|
||||
} else {
|
||||
sql = `
|
||||
select
|
||||
g.t as x,
|
||||
g.t as x,
|
||||
g.y as y
|
||||
from (
|
||||
select
|
||||
date_trunc('${unit}', created_at) as t,
|
||||
${getDateSQL('website_event.created_at', unit, timezone)} as t,
|
||||
uniq(session_id) as y
|
||||
from website_event_stats_hourly website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
|
Loading…
Reference in New Issue
Block a user