Skip to content

Commit

Permalink
added the calls
Browse files Browse the repository at this point in the history
  • Loading branch information
yogesh1801 committed Jul 3, 2024
1 parent efb8cad commit 271c991
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
4 changes: 0 additions & 4 deletions apps/api/src/common/get-secrets-of-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,8 +64,6 @@ export default async function getAllSecretsOfProject(
}
}
},
skip: page * limit,
take: limit,
orderBy: {
[sort]: order
}
Expand Down
4 changes: 0 additions & 4 deletions apps/api/src/common/get-variables-of-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,8 +41,6 @@ export default async function getAllVariablesOfProject(
}
}
},
skip: page * limit,
take: limit,
orderBy: {
[sort]: order
}
Expand Down
48 changes: 47 additions & 1 deletion apps/api/src/project/service/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -638,7 +641,7 @@ export class ProjectService {
prisma: this.prisma
})

return (
const projects = (
await this.prisma.project.findMany({
skip: page * limit,
take: limit,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 271c991

Please sign in to comment.