3.1 relational bug fixes
This commit is contained in:
@@ -8,6 +8,7 @@ import { WebsiteFilterButton } from '@/components/input/WebsiteFilterButton';
|
|||||||
export function WebsiteControls({
|
export function WebsiteControls({
|
||||||
websiteId,
|
websiteId,
|
||||||
allowFilter = true,
|
allowFilter = true,
|
||||||
|
allowBounceFilter = false,
|
||||||
allowDateFilter = true,
|
allowDateFilter = true,
|
||||||
allowMonthFilter,
|
allowMonthFilter,
|
||||||
allowDownload = false,
|
allowDownload = false,
|
||||||
@@ -25,7 +26,7 @@ export function WebsiteControls({
|
|||||||
<Column gap>
|
<Column gap>
|
||||||
<Grid columns={{ base: '1fr', md: 'auto 1fr' }} gap>
|
<Grid columns={{ base: '1fr', md: 'auto 1fr' }} gap>
|
||||||
<Row alignItems="center" justifyContent="flex-start" gap="4">
|
<Row alignItems="center" justifyContent="flex-start" gap="4">
|
||||||
{allowFilter && <WebsiteFilterButton websiteId={websiteId} />}
|
{allowFilter && <WebsiteFilterButton websiteId={websiteId} allowBounceFilter={allowBounceFilter} />}
|
||||||
</Row>
|
</Row>
|
||||||
<Row alignItems="center" justifyContent={{ base: 'flex-start', md: 'flex-end' }}>
|
<Row alignItems="center" justifyContent={{ base: 'flex-start', md: 'flex-end' }}>
|
||||||
{allowDateFilter && (
|
{allowDateFilter && (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { AlignEndHorizontal, Clock, Eye, PanelLeft, Sheet, Tag, User } from '@/c
|
|||||||
import { LanguageButton } from '@/components/input/LanguageButton';
|
import { LanguageButton } from '@/components/input/LanguageButton';
|
||||||
import { PreferencesButton } from '@/components/input/PreferencesButton';
|
import { PreferencesButton } from '@/components/input/PreferencesButton';
|
||||||
import { Funnel, Gauge, Lightning, Magnet, Money, Network, Path, Target } from '@/components/svg';
|
import { Funnel, Gauge, Lightning, Magnet, Money, Network, Path, Target } from '@/components/svg';
|
||||||
|
import { buildPath } from '@/lib/url';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Column,
|
Column,
|
||||||
@@ -29,10 +30,18 @@ export function ShareNav({
|
|||||||
}) {
|
}) {
|
||||||
const share = useShare();
|
const share = useShare();
|
||||||
const { t, labels } = useMessages();
|
const { t, labels } = useMessages();
|
||||||
const { pathname } = useNavigation();
|
const { pathname, query } = useNavigation();
|
||||||
const { slug, parameters } = share;
|
const { slug, parameters } = share;
|
||||||
|
|
||||||
const renderPath = (path: string) => `/share/${slug}${path}`;
|
const renderPath = (path: string) =>
|
||||||
|
buildPath(`/share/${slug}${path}`, {
|
||||||
|
...query,
|
||||||
|
event: undefined,
|
||||||
|
compare: undefined,
|
||||||
|
view: undefined,
|
||||||
|
unit: undefined,
|
||||||
|
excludeBounce: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
const allItems = [
|
const allItems = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import { filtersArrayToObject } from '@/lib/params';
|
|||||||
|
|
||||||
export function WebsiteFilterButton({
|
export function WebsiteFilterButton({
|
||||||
websiteId,
|
websiteId,
|
||||||
|
allowBounceFilter,
|
||||||
}: {
|
}: {
|
||||||
websiteId?: string;
|
websiteId?: string;
|
||||||
|
allowBounceFilter?: boolean;
|
||||||
position?: 'bottom' | 'top' | 'left' | 'right';
|
position?: 'bottom' | 'top' | 'left' | 'right';
|
||||||
alignment?: 'end' | 'center' | 'start';
|
alignment?: 'end' | 'center' | 'start';
|
||||||
}) {
|
}) {
|
||||||
@@ -41,7 +43,7 @@ export function WebsiteFilterButton({
|
|||||||
{({ close }) => {
|
{({ close }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isOverview && (
|
{(isOverview || allowBounceFilter) && (
|
||||||
<Row position="absolute" top="30px" right="30px">
|
<Row position="absolute" top="30px" right="30px">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
value={excludeBounce ? 'true' : ''}
|
value={excludeBounce ? 'true' : ''}
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ function mapFilter(
|
|||||||
case OPERATORS.doesNotContain:
|
case OPERATORS.doesNotContain:
|
||||||
return `positionCaseInsensitive(${column}, ${value}) = 0`;
|
return `positionCaseInsensitive(${column}, ${value}) = 0`;
|
||||||
case OPERATORS.regex:
|
case OPERATORS.regex:
|
||||||
return `match(${column}, ${value})`;
|
return `match(${column}, concat('(?i)', ${value}))`;
|
||||||
case OPERATORS.notRegex:
|
case OPERATORS.notRegex:
|
||||||
return `not match(${column}, ${value})`;
|
return `not match(${column}, concat('(?i)', ${value}))`;
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ function getCohortQuery(filters: Record<string, any>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getExcludeBounceQuery(filters: Record<string, any>) {
|
function getExcludeBounceQuery(filters: Record<string, any>) {
|
||||||
if (!filters.excludeBounce === true) {
|
if (filters.excludeBounce !== true) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -97,9 +97,9 @@ function mapFilter(
|
|||||||
case OPERATORS.doesNotContain:
|
case OPERATORS.doesNotContain:
|
||||||
return `${table}.${column} not ilike ${value}`;
|
return `${table}.${column} not ilike ${value}`;
|
||||||
case OPERATORS.regex:
|
case OPERATORS.regex:
|
||||||
return `${table}.${column} ~ ${value}`;
|
return `${table}.${column} ~* ${value}`;
|
||||||
case OPERATORS.notRegex:
|
case OPERATORS.notRegex:
|
||||||
return `${table}.${column} !~ ${value}`;
|
return `${table}.${column} !~* ${value}`;
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ function getCohortQuery(filters: QueryFilters = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getExcludeBounceQuery(filters: Record<string, any>) {
|
function getExcludeBounceQuery(filters: Record<string, any>) {
|
||||||
if (!filters.excludeBounce === true) {
|
if (filters.excludeBounce !== true) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ async function rawQuery(sql: string, data: Record<string, any>, name?: string):
|
|||||||
if (process.env.DATABASE_REPLICA_URL && '$replica' in client) {
|
if (process.env.DATABASE_REPLICA_URL && '$replica' in client) {
|
||||||
return client.$replica().$queryRawUnsafe(query, ...params);
|
return client.$replica().$queryRawUnsafe(query, ...params);
|
||||||
}
|
}
|
||||||
|
console.log(query, params);
|
||||||
return client.$queryRawUnsafe(query, ...params);
|
return client.$queryRawUnsafe(query, ...params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ async function relationalQuery(
|
|||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
and website_event.event_type NOT IN (2, 5)
|
and website_event.event_type NOT IN (2, 5)
|
||||||
|
and ${column} != ''
|
||||||
${excludeDomain}
|
${excludeDomain}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by 1
|
group by 1
|
||||||
@@ -142,6 +143,7 @@ async function clickhouseQuery(
|
|||||||
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}
|
||||||
and event_type NOT IN (2, 5)
|
and event_type NOT IN (2, 5)
|
||||||
|
and ${column} != ''
|
||||||
${excludeDomain}
|
${excludeDomain}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by x
|
group by x
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ async function relationalQuery(websiteId: string, filters: QueryFilters, session
|
|||||||
|
|
||||||
const joinQuery =
|
const joinQuery =
|
||||||
filterQuery || cohortQuery
|
filterQuery || cohortQuery
|
||||||
? `join (select distinct website_id, session_id, visit_id
|
? `join (select distinct website_event.website_id, website_event.session_id, website_event.visit_id
|
||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
${filterQuery}) website_event
|
${filterQuery}) website_event
|
||||||
on website_event.website_id = sr.website_id
|
on website_event.website_id = sr.website_id
|
||||||
and website_event.session_id = sr.session_id
|
and website_event.session_id = sr.session_id
|
||||||
|
|||||||
@@ -58,8 +58,9 @@ async function relationalQuery(
|
|||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
and website_event.event_type NOT IN (2, 5)
|
and website_event.event_type NOT IN (2, 5)
|
||||||
|
and ${column} != ''
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by 1
|
group by 1
|
||||||
${includeCountry ? ', 3' : ''}
|
${includeCountry ? ', 3' : ''}
|
||||||
order by 2 desc
|
order by 2 desc
|
||||||
limit ${limit}
|
limit ${limit}
|
||||||
@@ -102,8 +103,9 @@ async function clickhouseQuery(
|
|||||||
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}
|
||||||
and event_type NOT IN (2, 5)
|
and event_type NOT IN (2, 5)
|
||||||
|
and ${column} != ''
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by x
|
group by x
|
||||||
${includeCountry ? ', country' : ''}
|
${includeCountry ? ', country' : ''}
|
||||||
order by y desc
|
order by y desc
|
||||||
limit ${limit}
|
limit ${limit}
|
||||||
@@ -121,6 +123,7 @@ async function clickhouseQuery(
|
|||||||
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}
|
||||||
and event_type NOT IN (2, 5)
|
and event_type NOT IN (2, 5)
|
||||||
|
and ${column} != ''
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by x
|
group by x
|
||||||
${includeCountry ? ', country' : ''}
|
${includeCountry ? ', country' : ''}
|
||||||
|
|||||||
Reference in New Issue
Block a user