rename all db columns
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { Widget } from '@/components/widget';
|
||||
import { escape } from 'sqlstring';
|
||||
|
||||
import { db, getEvents } from '@openpanel/db';
|
||||
@@ -12,7 +11,7 @@ interface Props {
|
||||
export default async function EventConversionsListServer({ projectId }: Props) {
|
||||
const conversions = await db.eventMeta.findMany({
|
||||
where: {
|
||||
project_id: projectId,
|
||||
projectId,
|
||||
conversion: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -145,7 +145,7 @@ export default function LayoutMenu({ dashboards }: LayoutMenuProps) {
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
href={`/${item.organization_slug}/${item.project_id}/dashboards/${item.id}`}
|
||||
href={`/${item.organizationSlug}/${item.projectId}/dashboards/${item.id}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@ import OverviewTopGeo from '@/components/overview/overview-top-geo';
|
||||
import OverviewTopPages from '@/components/overview/overview-top-pages';
|
||||
import OverviewTopSources from '@/components/overview/overview-top-sources';
|
||||
|
||||
import { db } from '@openpanel/db';
|
||||
import { getShareByProjectId } from '@openpanel/db';
|
||||
|
||||
import OverviewMetrics from '../../../../components/overview/overview-metrics';
|
||||
import { StickyBelowHeader } from './layout-sticky-below-header';
|
||||
@@ -26,11 +26,7 @@ interface PageProps {
|
||||
export default async function Page({
|
||||
params: { organizationId, projectId },
|
||||
}: PageProps) {
|
||||
const share = await db.shareOverview.findUnique({
|
||||
where: {
|
||||
project_id: projectId,
|
||||
},
|
||||
});
|
||||
const share = await getShareByProjectId(projectId);
|
||||
|
||||
return (
|
||||
<PageLayout title="Overview" organizationSlug={organizationId}>
|
||||
|
||||
@@ -57,7 +57,7 @@ export default function ListProjects({ projects, clients }: ListProjectsProps) {
|
||||
<Accordion type="single" collapsible className="-mx-4">
|
||||
{projects.map((project) => {
|
||||
const pClients = clients.filter(
|
||||
(client) => client.project_id === project.id
|
||||
(client) => client.projectId === project.id
|
||||
);
|
||||
return (
|
||||
<AccordionItem
|
||||
|
||||
@@ -16,7 +16,7 @@ export default async function Page({
|
||||
}: PageProps) {
|
||||
const references = await getReferences({
|
||||
where: {
|
||||
project_id: projectId,
|
||||
projectId,
|
||||
},
|
||||
take: 50,
|
||||
skip: 0,
|
||||
|
||||
@@ -28,8 +28,8 @@ export default async function Page({ params: { id } }: PageProps) {
|
||||
if (!share.public) {
|
||||
return notFound();
|
||||
}
|
||||
const projectId = share.project_id;
|
||||
const organization = await getOrganizationBySlug(share.organization_slug);
|
||||
const projectId = share.projectId;
|
||||
const organization = await getOrganizationBySlug(share.organizationSlug);
|
||||
|
||||
return (
|
||||
<div className="bg-gradient-to-tl from-blue-950 to-blue-600 p-4 md:p-16">
|
||||
|
||||
@@ -12,9 +12,9 @@ export async function POST(request: Request) {
|
||||
data: access
|
||||
.filter((a): a is string => typeof a === 'string')
|
||||
.map((projectId) => ({
|
||||
organization_slug: payload.data.organization.slug!,
|
||||
project_id: projectId,
|
||||
user_id: payload.data.public_user_data.user_id,
|
||||
organizationSlug: payload.data.organization.slug!,
|
||||
projectId: projectId,
|
||||
userId: payload.data.public_user_data.user_id,
|
||||
level: AccessLevel.read,
|
||||
})),
|
||||
});
|
||||
@@ -23,8 +23,8 @@ export async function POST(request: Request) {
|
||||
if (payload.type === 'organizationMembership.deleted') {
|
||||
await db.projectAccess.deleteMany({
|
||||
where: {
|
||||
organization_slug: payload.data.organization.slug!,
|
||||
user_id: payload.data.public_user_data.user_id,
|
||||
organizationSlug: payload.data.organization.slug!,
|
||||
userId: payload.data.public_user_data.user_id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ export function OverviewShare({ data }: OverviewShareProps) {
|
||||
onClick={() => {
|
||||
mutation.mutate({
|
||||
public: false,
|
||||
projectId: data?.project_id,
|
||||
organizationId: data?.organization_slug,
|
||||
projectId: data?.projectId,
|
||||
organizationId: data?.organizationSlug,
|
||||
password: null,
|
||||
});
|
||||
}}
|
||||
|
||||
@@ -8,10 +8,11 @@ import { popModal } from '..';
|
||||
|
||||
interface ModalContentProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function ModalContent({ children }: ModalContentProps) {
|
||||
return <DialogContent>{children}</DialogContent>;
|
||||
export function ModalContent({ children, className }: ModalContentProps) {
|
||||
return <DialogContent className={className}>{children}</DialogContent>;
|
||||
}
|
||||
|
||||
interface ModalHeaderProps {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createTRPCRouter, protectedProcedure } from '@/trpc/api/trpc';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { hashPassword, stripTrailingSlash } from '@openpanel/common';
|
||||
import { db, transformClient } from '@openpanel/db';
|
||||
import { db } from '@openpanel/db';
|
||||
|
||||
export const clientRouter = createTRPCRouter({
|
||||
list: protectedProcedure
|
||||
@@ -15,7 +15,7 @@ export const clientRouter = createTRPCRouter({
|
||||
.query(async ({ input: { organizationId } }) => {
|
||||
return db.client.findMany({
|
||||
where: {
|
||||
organization_slug: organizationId,
|
||||
organizationSlug: organizationId,
|
||||
},
|
||||
include: {
|
||||
project: true,
|
||||
@@ -67,8 +67,8 @@ export const clientRouter = createTRPCRouter({
|
||||
const secret = randomUUID();
|
||||
const client = await db.client.create({
|
||||
data: {
|
||||
organization_slug: input.organizationId,
|
||||
project_id: input.projectId,
|
||||
organizationSlug: input.organizationId,
|
||||
projectId: input.projectId,
|
||||
name: input.name,
|
||||
secret: input.cors ? null : await hashPassword(secret),
|
||||
cors: input.cors ? stripTrailingSlash(input.cors) : '*',
|
||||
@@ -76,7 +76,7 @@ export const clientRouter = createTRPCRouter({
|
||||
});
|
||||
|
||||
return {
|
||||
...transformClient(client),
|
||||
...client,
|
||||
secret: input.cors ? null : secret,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -28,8 +28,8 @@ export const dashboardRouter = createTRPCRouter({
|
||||
return db.dashboard.create({
|
||||
data: {
|
||||
id: await getId('dashboard', name),
|
||||
project_id: projectId,
|
||||
organization_slug: organizationSlug,
|
||||
projectId: projectId,
|
||||
organizationSlug: organizationSlug,
|
||||
name,
|
||||
},
|
||||
});
|
||||
@@ -63,7 +63,7 @@ export const dashboardRouter = createTRPCRouter({
|
||||
if (forceDelete) {
|
||||
await db.report.deleteMany({
|
||||
where: {
|
||||
dashboard_id: id,
|
||||
dashboardId: id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ export const eventRouter = createTRPCRouter({
|
||||
.mutation(({ input: { projectId, name, icon, color, conversion } }) => {
|
||||
return db.eventMeta.upsert({
|
||||
where: {
|
||||
name_project_id: {
|
||||
name_projectId: {
|
||||
name,
|
||||
project_id: projectId,
|
||||
projectId,
|
||||
},
|
||||
},
|
||||
create: { project_id: projectId, name, icon, color, conversion },
|
||||
create: { projectId, name, icon, color, conversion },
|
||||
update: { icon, color, conversion },
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -4,12 +4,7 @@ import { clerkClient } from '@clerk/nextjs';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { hashPassword, stripTrailingSlash } from '@openpanel/common';
|
||||
import {
|
||||
db,
|
||||
transformClient,
|
||||
transformOrganization,
|
||||
transformProject,
|
||||
} from '@openpanel/db';
|
||||
import { db, transformOrganization } from '@openpanel/db';
|
||||
|
||||
export const onboardingRouter = createTRPCRouter({
|
||||
organziation: protectedProcedure
|
||||
@@ -30,7 +25,7 @@ export const onboardingRouter = createTRPCRouter({
|
||||
const project = await db.project.create({
|
||||
data: {
|
||||
name: input.project,
|
||||
organization_slug: org.slug,
|
||||
organizationSlug: org.slug,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -38,19 +33,19 @@ export const onboardingRouter = createTRPCRouter({
|
||||
const client = await db.client.create({
|
||||
data: {
|
||||
name: `${project.name} Client`,
|
||||
organization_slug: org.slug,
|
||||
project_id: project.id,
|
||||
organizationSlug: org.slug,
|
||||
projectId: project.id,
|
||||
cors: input.cors ? stripTrailingSlash(input.cors) : '*',
|
||||
secret: input.cors ? null : await hashPassword(secret),
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
client: transformClient({
|
||||
client: {
|
||||
...client,
|
||||
secret: input.cors ? null : secret,
|
||||
}),
|
||||
project: transformProject(project),
|
||||
},
|
||||
project,
|
||||
organization: transformOrganization(org),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,15 +77,15 @@ export const organizationRouter = createTRPCRouter({
|
||||
return db.$transaction([
|
||||
db.projectAccess.deleteMany({
|
||||
where: {
|
||||
user_id: input.userId,
|
||||
organization_slug: input.organizationSlug,
|
||||
userId: input.userId,
|
||||
organizationSlug: input.organizationSlug,
|
||||
},
|
||||
}),
|
||||
db.projectAccess.createMany({
|
||||
data: input.access.map((projectId) => ({
|
||||
user_id: input.userId,
|
||||
organization_slug: input.organizationSlug,
|
||||
project_id: projectId,
|
||||
userId: input.userId,
|
||||
organizationSlug: input.organizationSlug,
|
||||
projectId: projectId,
|
||||
level: 'read',
|
||||
})),
|
||||
}),
|
||||
|
||||
@@ -44,7 +44,7 @@ export const projectRouter = createTRPCRouter({
|
||||
return db.project.create({
|
||||
data: {
|
||||
id: await getId('project', input.name),
|
||||
organization_slug: input.organizationId,
|
||||
organizationSlug: input.organizationId,
|
||||
name: input.name,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ export const referenceRouter = createTRPCRouter({
|
||||
data: {
|
||||
title,
|
||||
description,
|
||||
project_id: projectId,
|
||||
projectId,
|
||||
date: new Date(datetime),
|
||||
},
|
||||
});
|
||||
@@ -47,7 +47,7 @@ export const referenceRouter = createTRPCRouter({
|
||||
const { startDate, endDate } = getChartStartEndDate(input);
|
||||
return getReferences({
|
||||
where: {
|
||||
project_id: projectId,
|
||||
projectId,
|
||||
date: {
|
||||
gte: new Date(startDate),
|
||||
lte: new Date(endDate),
|
||||
|
||||
@@ -20,14 +20,14 @@ export const reportRouter = createTRPCRouter({
|
||||
});
|
||||
return db.report.create({
|
||||
data: {
|
||||
project_id: dashboard.project_id,
|
||||
dashboard_id: dashboardId,
|
||||
projectId: dashboard.projectId,
|
||||
dashboardId,
|
||||
name: report.name,
|
||||
events: report.events,
|
||||
interval: report.interval,
|
||||
breakdowns: report.breakdowns,
|
||||
chart_type: report.chartType,
|
||||
line_type: report.lineType,
|
||||
chartType: report.chartType,
|
||||
lineType: report.lineType,
|
||||
range: report.range,
|
||||
formula: report.formula,
|
||||
},
|
||||
@@ -50,8 +50,8 @@ export const reportRouter = createTRPCRouter({
|
||||
events: report.events,
|
||||
interval: report.interval,
|
||||
breakdowns: report.breakdowns,
|
||||
chart_type: report.chartType,
|
||||
line_type: report.lineType,
|
||||
chartType: report.chartType,
|
||||
lineType: report.lineType,
|
||||
range: report.range,
|
||||
formula: report.formula,
|
||||
},
|
||||
|
||||
@@ -12,12 +12,12 @@ export const shareRouter = createTRPCRouter({
|
||||
.mutation(({ input }) => {
|
||||
return db.shareOverview.upsert({
|
||||
where: {
|
||||
project_id: input.projectId,
|
||||
projectId: input.projectId,
|
||||
},
|
||||
create: {
|
||||
id: uid.rnd(),
|
||||
organization_slug: input.organizationId,
|
||||
project_id: input.projectId,
|
||||
organizationSlug: input.organizationId,
|
||||
projectId: input.projectId,
|
||||
public: input.public,
|
||||
password: input.password || null,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user