Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: project related typeorm stuff

Blue Mouse3758b22d521c
diff --git a/backend/apps/production/src/alert/alert.controller.ts b/backend/apps/production/src/alert/alert.controller.ts
index 6cdf557e6..863360ad7 100644
--- a/backend/apps/production/src/alert/alert.controller.ts
+++ b/backend/apps/production/src/alert/alert.controller.ts
@@ -102,14 +102,12 @@ export class AlertController {
throw new ForbiddenException('Please, verify your email address first')
}
- const project = await this.projectService.findOneWhere(
- {
+ const project = await this.projectService.findOne({
+ where: {
id: alertDTO.pid,
},
- {
- relations: ['alerts', 'admin'],
- },
- )
+ relations: ['alerts', 'admin'],
+ })
if (_isEmpty(project)) {
throw new NotFoundException('Project not found')
diff --git a/backend/apps/production/src/project/project.controller.ts b/backend/apps/production/src/project/project.controller.ts
index 7022f02eb..de6486434 100644
--- a/backend/apps/production/src/project/project.controller.ts
+++ b/backend/apps/production/src/project/project.controller.ts
@@ -575,15 +575,15 @@ export class ProjectController {
)
}
- const project = await this.projectService.findOneWhere(
- {
+ const project = await this.projectService.findOne({
+ where: {
id: funnelDTO.pid,
- admin: userId,
- },
- {
- relations: ['admin', 'share'],
+ admin: {
+ id: userId,
+ },
},
- )
+ relations: ['admin', 'share'],
+ })
if (!project) {
throw new NotFoundException('Project not found.')
@@ -630,15 +630,15 @@ export class ProjectController {
)
}
- const project = await this.projectService.findOneWhere(
- {
+ const project = await this.projectService.findOne({
+ where: {
id: funnelDTO.pid,
- admin: userId,
- },
- {
- relations: ['admin', 'share', 'funnels'],
+ admin: {
+ id: userId,
+ },
},
- )
+ relations: ['admin', 'share', 'funnels'],
+ })
if (!project) {
throw new NotFoundException('Project not found.')
@@ -682,15 +682,15 @@ export class ProjectController {
throw new UnauthorizedException('Please auth first')
}
- const project = await this.projectService.findOneWhere(
- {
+ const project = await this.projectService.findOne({
+ where: {
id: pid,
- admin: userId,
- },
- {
- relations: ['admin', 'share'],
+ admin: {
+ id: userId,
+ },
},
- )
+ relations: ['admin', 'share'],
+ })
if (!project) {
throw new NotFoundException('Project not found')
@@ -750,13 +750,11 @@ export class ProjectController {
}
const user = await this.userService.findOne({ where: { id: uid } })
- const project = await this.projectService.findOneWhere(
- { id },
- {
- relations: ['admin'],
- select: ['id'],
- },
- )
+ const project = await this.projectService.findOne({
+ where: { id },
+ relations: ['admin'],
+ select: ['id'],
+ })
if (_isEmpty(project)) {
throw new NotFoundException(`Project with ID ${id} does not exist`)
@@ -808,13 +806,11 @@ export class ProjectController {
}
const user = await this.userService.findOne({ where: { id: uid } })
- const project = await this.projectService.findOneWhere(
- { id },
- {
- relations: ['admin'],
- select: ['id'],
- },
- )
+ const project = await this.projectService.findOne({
+ where: { id },
+ relations: ['admin'],
+ select: ['id'],
+ })
if (_isEmpty(project)) {
throw new NotFoundException(`Project with ID ${id} does not exist`)
@@ -895,13 +891,11 @@ export class ProjectController {
}
const user = await this.userService.findOne({ where: { id: uid } })
- const project = await this.projectService.findOneWhere(
- { id },
- {
- relations: ['admin'],
- select: ['id'],
- },
- )
+ const project = await this.projectService.findOne({
+ where: { id },
+ relations: ['admin'],
+ select: ['id'],
+ })
if (_isEmpty(project)) {
throw new NotFoundException(`Project with ID ${id} does not exist`)
@@ -1096,13 +1090,11 @@ export class ProjectController {
continue
}
- const project = await this.projectService.findOneWhere(
- { id: pid },
- {
- relations: ['admin', 'share', 'share.user'],
- select: ['id', 'admin', 'share'],
- },
- )
+ const project = await this.projectService.findOne({
+ where: { id: pid },
+ relations: ['admin', 'share', 'share.user'],
+ select: ['id', 'admin', 'share'],
+ })
if (_isEmpty(project)) {
this.logger.warn(`Project with ID ${pid} does not exist`)
@@ -1207,13 +1199,11 @@ export class ProjectController {
}
const user = await this.userService.findOne({ where: { id: uid } })
- const project = await this.projectService.findOneWhere(
- { id: pid },
- {
- relations: ['admin', 'share', 'share.user'],
- select: ['id', 'admin', 'share'],
- },
- )
+ const project = await this.projectService.findOne({
+ where: { id: pid },
+ relations: ['admin', 'share', 'share.user'],
+ select: ['id', 'admin', 'share'],
+ })
if (_isEmpty(project)) {
throw new NotFoundException(`Project with ID ${pid} does not exist`)
@@ -1740,13 +1730,11 @@ export class ProjectController {
)
}
const user = await this.userService.findOne({ where: { id: uid } })
- const project = await this.projectService.findOneWhere(
- { id },
- {
- relations: ['admin'],
- select: ['id'],
- },
- )
+ const project = await this.projectService.findOne({
+ where: { id },
+ relations: ['admin'],
+ select: ['id'],
+ })
if (_isEmpty(project)) {
throw new NotFoundException(`Project with ID ${id} does not exist`)
@@ -2052,13 +2040,11 @@ export class ProjectController {
)
}
- const project = await this.projectService.findOneWhere(
- { id: pid },
- {
- relations: ['admin', 'share', 'share.user'],
- select: ['id', 'admin', 'share'],
- },
- )
+ const project = await this.projectService.findOne({
+ where: { id: pid },
+ relations: ['admin', 'share', 'share.user'],
+ select: ['id', 'admin', 'share'],
+ })
if (_isEmpty(project)) {
throw new NotFoundException(`Project with ID ${pid} does not exist`)
diff --git a/backend/apps/production/src/project/project.service.ts b/backend/apps/production/src/project/project.service.ts
index 89ea1a402..236508709 100644
--- a/backend/apps/production/src/project/project.service.ts
+++ b/backend/apps/production/src/project/project.service.ts
@@ -493,13 +493,6 @@ export class ProjectService {
return this.projectsRepository.find(options)
}
- findOneWhere(
- where: Record<string, unknown>,
- options: Omit<FindOneOptions<Project>, 'where'> = {},
- ) {
- return this.projectsRepository.findOne({ where, ...options })
- }
-
allowedToView(
project: Project,
uid: string | null,