Compare commits

...

2 commits

Author SHA1 Message Date
Francis Cao
912d2d544d Fix deleted website visibility bug
Some checks failed
Create docker images (cloud) / Build, push, and deploy (push) Has been cancelled
Node.js CI / build (postgresql, 18.18, 10) (push) Has been cancelled
Closes #3865
2025-12-19 14:21:42 -08:00
Francis Cao
3072f02f1b Add table alias to filterQuery. Closed  #3869
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
2025-12-19 13:32:20 -08:00
6 changed files with 33 additions and 8 deletions

View file

@ -1,8 +1,14 @@
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { getLink } from '@/queries/prisma';
import { LinkPage } from './LinkPage'; import { LinkPage } from './LinkPage';
export default async function ({ params }: { params: Promise<{ linkId: string }> }) { export default async function ({ params }: { params: Promise<{ linkId: string }> }) {
const { linkId } = await params; const { linkId } = await params;
const link = await getLink(linkId);
if (!link || link?.deletedAt) {
return null;
}
return <LinkPage linkId={linkId} />; return <LinkPage linkId={linkId} />;
} }

View file

@ -1,8 +1,14 @@
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { getPixel } from '@/queries/prisma';
import { PixelPage } from './PixelPage'; import { PixelPage } from './PixelPage';
export default async function ({ params }: { params: { pixelId: string } }) { export default async function ({ params }: { params: { pixelId: string } }) {
const { pixelId } = await params; const { pixelId } = await params;
const pixel = await getPixel(pixelId);
if (!pixel || pixel?.deletedAt) {
return null;
}
return <PixelPage pixelId={pixelId} />; return <PixelPage pixelId={pixelId} />;
} }

View file

@ -1,5 +1,6 @@
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { WebsiteLayout } from '@/app/(main)/websites/[websiteId]/WebsiteLayout'; import { WebsiteLayout } from '@/app/(main)/websites/[websiteId]/WebsiteLayout';
import { getWebsite } from '@/queries/prisma';
export default async function ({ export default async function ({
children, children,
@ -9,6 +10,11 @@ export default async function ({
params: Promise<{ websiteId: string }>; params: Promise<{ websiteId: string }>;
}) { }) {
const { websiteId } = await params; const { websiteId } = await params;
const website = await getWebsite(websiteId);
if (!website || website?.deletedAt) {
return null;
}
return <WebsiteLayout websiteId={websiteId}>{children}</WebsiteLayout>; return <WebsiteLayout websiteId={websiteId}>{children}</WebsiteLayout>;
} }

View file

@ -74,15 +74,21 @@ function getSearchSQL(column: string, param: string = 'search'): string {
function mapFilter(column: string, operator: string, name: string, type: string = '') { function mapFilter(column: string, operator: string, name: string, type: string = '') {
const value = `{{${name}${type ? `::${type}` : ''}}}`; const value = `{{${name}${type ? `::${type}` : ''}}}`;
if (name.startsWith('cohort_')) {
name = name.slice('cohort_'.length);
}
const table = SESSION_COLUMNS.includes(name) ? 'session' : 'website_event';
switch (operator) { switch (operator) {
case OPERATORS.equals: case OPERATORS.equals:
return `${column} = ${value}`; return `${table}.${column} = ${value}`;
case OPERATORS.notEquals: case OPERATORS.notEquals:
return `${column} != ${value}`; return `${table}.${column} != ${value}`;
case OPERATORS.contains: case OPERATORS.contains:
return `${column} ilike ${value}`; return `${table}.${column} ilike ${value}`;
case OPERATORS.doesNotContain: case OPERATORS.doesNotContain:
return `${column} not ilike ${value}`; return `${table}.${column} not ilike ${value}`;
default: default:
return ''; return '';
} }

View file

@ -85,7 +85,7 @@ export async function setWebsiteDate(websiteId: string, userId: string, data: Re
const website = await fetchWebsite(websiteId); const website = await fetchWebsite(websiteId);
const cloudMode = !!process.env.CLOUD_MODE; const cloudMode = !!process.env.CLOUD_MODE;
if (cloudMode && !website.teamId) { if (cloudMode && website && !website.teamId) {
const account = await fetchAccount(userId); const account = await fetchAccount(userId);
if (!account?.hasSubscription) { if (!account?.hasSubscription) {

View file

@ -41,7 +41,8 @@ async function relationalQuery(
currency, currency,
}); });
const joinQuery = filterQuery const joinQuery =
filterQuery || cohortQuery
? `join website_event ? `join website_event
on website_event.website_id = revenue.website_id on website_event.website_id = revenue.website_id
and website_event.session_id = revenue.session_id and website_event.session_id = revenue.session_id