diff --git a/apps/api/src/common/get-secrets-of-project.ts b/apps/api/src/common/get-secrets-of-project.ts index 9b1f4cbe..750c3b28 100644 --- a/apps/api/src/common/get-secrets-of-project.ts +++ b/apps/api/src/common/get-secrets-of-project.ts @@ -34,8 +34,6 @@ export default async function getAllSecretsOfProject( user: User, projectId: Project['id'], decryptValue: boolean, - page: number, - limit: number, sort: string, order: string, search: string @@ -66,8 +64,6 @@ export default async function getAllSecretsOfProject( } } }, - skip: page * limit, - take: limit, orderBy: { [sort]: order } diff --git a/apps/api/src/common/get-variables-of-project.ts b/apps/api/src/common/get-variables-of-project.ts index 061f8c2a..1d42c360 100644 --- a/apps/api/src/common/get-variables-of-project.ts +++ b/apps/api/src/common/get-variables-of-project.ts @@ -14,8 +14,6 @@ export default async function getAllVariablesOfProject( authorityCheckerService: AuthorityCheckerService, user: User, projectId: Project['id'], - page: number, - limit: number, sort: string, order: string, search: string @@ -43,8 +41,6 @@ export default async function getAllVariablesOfProject( } } }, - skip: page * limit, - take: limit, orderBy: { [sort]: order } diff --git a/apps/api/src/project/service/project.service.ts b/apps/api/src/project/service/project.service.ts index 18253372..a2c5f12f 100644 --- a/apps/api/src/project/service/project.service.ts +++ b/apps/api/src/project/service/project.service.ts @@ -29,6 +29,9 @@ import createEvent from '../../common/create-event' import { ProjectWithSecrets } from '../project.types' import { AuthorityCheckerService } from '../../common/authority-checker.service' import { ForkProject } from '../dto/fork.project/fork.project' +import getEnvironmentsOfProject from 'src/common/get-environmets-of-project' +import getAllVariablesOfProject from 'src/common/get-variables-of-project' +import getAllSecretsOfProject from 'src/common/get-secrets-of-project' @Injectable() export class ProjectService { @@ -638,7 +641,7 @@ export class ProjectService { prisma: this.prisma }) - return ( + const projects = ( await this.prisma.project.findMany({ skip: page * limit, take: limit, @@ -669,6 +672,49 @@ export class ProjectService { } }) ).map((project) => excludeFields(project, 'privateKey', 'publicKey')) + + const response = await Promise.all( + projects.map(async (project) => { + const totalenvironmets = await getEnvironmentsOfProject( + this.prisma, + this.authorityCheckerService, + user, + project.id, + 'name', + 'asc', + '' + ) + const totalvariables = await getAllVariablesOfProject( + this.prisma, + this.authorityCheckerService, + user, + project.id, + 'name', + 'asc', + '' + ) + const totalsecrets = await getAllSecretsOfProject( + this.prisma, + this.authorityCheckerService, + user, + project.id, + false, + 'name', + 'asc', + '' + ) + + // Append counts to the project object + return { + ...project, + totalenvironmets, + totalvariables, + totalsecrets + } + }) + ) + + return response } private async projectExists(