3.1 relational bug fixes

This commit is contained in:
Francis Cao
2026-04-15 10:31:21 -07:00
parent b7f51b3b01
commit 04eb4b675e
8 changed files with 33 additions and 16 deletions
@@ -8,6 +8,7 @@ import { WebsiteFilterButton } from '@/components/input/WebsiteFilterButton';
export function WebsiteControls({
websiteId,
allowFilter = true,
allowBounceFilter = false,
allowDateFilter = true,
allowMonthFilter,
allowDownload = false,
@@ -25,7 +26,7 @@ export function WebsiteControls({
<Column gap>
<Grid columns={{ base: '1fr', md: 'auto 1fr' }} gap>
<Row alignItems="center" justifyContent="flex-start" gap="4">
{allowFilter && <WebsiteFilterButton websiteId={websiteId} />}
{allowFilter && <WebsiteFilterButton websiteId={websiteId} allowBounceFilter={allowBounceFilter} />}
</Row>
<Row alignItems="center" justifyContent={{ base: 'flex-start', md: 'flex-end' }}>
{allowDateFilter && (
+11 -2
View File
@@ -4,6 +4,7 @@ import { AlignEndHorizontal, Clock, Eye, PanelLeft, Sheet, Tag, User } from '@/c
import { LanguageButton } from '@/components/input/LanguageButton';
import { PreferencesButton } from '@/components/input/PreferencesButton';
import { Funnel, Gauge, Lightning, Magnet, Money, Network, Path, Target } from '@/components/svg';
import { buildPath } from '@/lib/url';
import {
Button,
Column,
@@ -29,10 +30,18 @@ export function ShareNav({
}) {
const share = useShare();
const { t, labels } = useMessages();
const { pathname } = useNavigation();
const { pathname, query } = useNavigation();
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 = [
{
+3 -1
View File
@@ -8,8 +8,10 @@ import { filtersArrayToObject } from '@/lib/params';
export function WebsiteFilterButton({
websiteId,
allowBounceFilter,
}: {
websiteId?: string;
allowBounceFilter?: boolean;
position?: 'bottom' | 'top' | 'left' | 'right';
alignment?: 'end' | 'center' | 'start';
}) {
@@ -41,7 +43,7 @@ export function WebsiteFilterButton({
{({ close }) => {
return (
<>
{isOverview && (
{(isOverview || allowBounceFilter) && (
<Row position="absolute" top="30px" right="30px">
<Checkbox
value={excludeBounce ? 'true' : ''}
+3 -3
View File
@@ -90,9 +90,9 @@ function mapFilter(
case OPERATORS.doesNotContain:
return `positionCaseInsensitive(${column}, ${value}) = 0`;
case OPERATORS.regex:
return `match(${column}, ${value})`;
return `match(${column}, concat('(?i)', ${value}))`;
case OPERATORS.notRegex:
return `not match(${column}, ${value})`;
return `not match(${column}, concat('(?i)', ${value}))`;
default:
return '';
}
@@ -161,7 +161,7 @@ function getCohortQuery(filters: Record<string, any>) {
}
function getExcludeBounceQuery(filters: Record<string, any>) {
if (!filters.excludeBounce === true) {
if (filters.excludeBounce !== true) {
return '';
}
+4 -4
View File
@@ -97,9 +97,9 @@ function mapFilter(
case OPERATORS.doesNotContain:
return `${table}.${column} not ilike ${value}`;
case OPERATORS.regex:
return `${table}.${column} ~ ${value}`;
return `${table}.${column} ~* ${value}`;
case OPERATORS.notRegex:
return `${table}.${column} !~ ${value}`;
return `${table}.${column} !~* ${value}`;
default:
return '';
}
@@ -173,7 +173,7 @@ function getCohortQuery(filters: QueryFilters = {}) {
}
function getExcludeBounceQuery(filters: Record<string, any>) {
if (!filters.excludeBounce === true) {
if (filters.excludeBounce !== true) {
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) {
return client.$replica().$queryRawUnsafe(query, ...params);
}
console.log(query, params);
return client.$queryRawUnsafe(query, ...params);
}
@@ -82,6 +82,7 @@ async function relationalQuery(
where website_event.website_id = {{websiteId::uuid}}
and website_event.created_at between {{startDate}} and {{endDate}}
and website_event.event_type NOT IN (2, 5)
and ${column} != ''
${excludeDomain}
${filterQuery}
group by 1
@@ -142,6 +143,7 @@ async function clickhouseQuery(
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
and event_type NOT IN (2, 5)
and ${column} != ''
${excludeDomain}
${filterQuery}
group by x
+3 -3
View File
@@ -25,11 +25,11 @@ async function relationalQuery(websiteId: string, filters: QueryFilters, session
const joinQuery =
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
${cohortQuery}
where website_id = {{websiteId::uuid}}
and created_at between {{startDate}} and {{endDate}}
where website_event.website_id = {{websiteId::uuid}}
and website_event.created_at between {{startDate}} and {{endDate}}
${filterQuery}) website_event
on website_event.website_id = sr.website_id
and website_event.session_id = sr.session_id
@@ -58,8 +58,9 @@ async function relationalQuery(
where website_event.website_id = {{websiteId::uuid}}
and website_event.created_at between {{startDate}} and {{endDate}}
and website_event.event_type NOT IN (2, 5)
and ${column} != ''
${filterQuery}
group by 1
group by 1
${includeCountry ? ', 3' : ''}
order by 2 desc
limit ${limit}
@@ -102,8 +103,9 @@ async function clickhouseQuery(
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
and event_type NOT IN (2, 5)
and ${column} != ''
${filterQuery}
group by x
group by x
${includeCountry ? ', country' : ''}
order by y desc
limit ${limit}
@@ -121,6 +123,7 @@ async function clickhouseQuery(
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
and event_type NOT IN (2, 5)
and ${column} != ''
${filterQuery}
group by x
${includeCountry ? ', country' : ''}