Skip to content

Commit

Permalink
chore(api): Updated response types in environment service
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Jul 11, 2024
1 parent 4a8a089 commit b8a3ddd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
4 changes: 1 addition & 3 deletions apps/api/src/environment/environment.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,8 @@ describe('Environment Controller Tests', () => {
description: 'Environment 1 description updated',
projectId: project1.id,
lastUpdatedById: user1.id,
lastUpdatedBy: expect.any(Object),
createdAt: expect.any(String),
updatedAt: expect.any(String),
project: expect.any(Object)
updatedAt: expect.any(String)
})

environment1 = response.json()
Expand Down
31 changes: 20 additions & 11 deletions apps/api/src/environment/service/environment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ export class EnvironmentService {
id: user.id
}
}
},
include: {
project: true
}
})

Expand Down Expand Up @@ -115,13 +112,11 @@ export class EnvironmentService {
name: dto.name,
description: dto.description,
lastUpdatedById: user.id
},
include: {
project: true,
lastUpdatedBy: true
}
})

const project = environment.project

await createEvent(
{
triggeredBy: user,
Expand All @@ -134,13 +129,13 @@ export class EnvironmentService {
name: updatedEnvironment.name,
projectId: updatedEnvironment.projectId
},
workspaceId: updatedEnvironment.project.workspaceId
workspaceId: project.workspaceId
},
this.prisma
)

this.logger.log(
`Environment ${updatedEnvironment.name} updated in project ${updatedEnvironment.project.name} (${updatedEnvironment.project.id})`
`Environment ${updatedEnvironment.name} updated in project ${project.name} (${project.id})`
)

return updatedEnvironment
Expand All @@ -155,6 +150,8 @@ export class EnvironmentService {
prisma: this.prisma
})

delete environment.project

return environment
}

Expand Down Expand Up @@ -182,8 +179,20 @@ export class EnvironmentService {
contains: search
}
},
include: {
lastUpdatedBy: true
select: {
id: true,
name: true,
description: true,
createdAt: true,
updatedAt: true,
lastUpdatedBy: {
select: {
id: true,
email: true,
profilePictureUrl: true,
name: true
}
}
},
skip: page * limit,
take: limit,
Expand Down

0 comments on commit b8a3ddd

Please sign in to comment.