Skip to content

Commit

Permalink
Merge pull request #62 from VentionCapstone/fix/133_responses
Browse files Browse the repository at this point in the history
fix(update): response properties
  • Loading branch information
fasbrothers committed Jan 25, 2024
2 parents 2781541 + 4fe4c19 commit 63a041c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/accommodation/accommodation.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ export class AccommodationController {
@LangQuery()
@Get('/:id')
async findOne(@Param('id') id: string) {
const { accommodation, owner } = await this.accommodationService.getOneAccommodation(id);
return { success: true, data: { ...accommodation, owner } };
const data = await this.accommodationService.getOneAccommodation(id);
return { success: true, data };
}

@ApiOperation({ summary: 'get all media of single accommodation' })
Expand Down
7 changes: 6 additions & 1 deletion src/accommodation/accommodation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class AccommodationService {
},
});

return { accommodation, owner };
return { ...accommodation, owner, amenities: accommodation.amenities[0] };
} catch (error) {
throw new GlobalException(ErrorsTypes.ACCOMMODATION_FAILED_TO_GET, error.message);
}
Expand Down Expand Up @@ -364,6 +364,10 @@ export class AccommodationService {
const totalPriceStatsQuery = this.prisma.accommodation.aggregate({
_min: { price: true },
_max: { price: true },
where: {
available: true,
isDeleted: false,
},
});

const [accommodations, totalCount, curPriceStats, totalPriceStats] = await Promise.all([
Expand Down Expand Up @@ -501,6 +505,7 @@ export class AccommodationService {
id: true,
title: true,
thumbnailUrl: true,
previewImgUrl: true,
squareMeters: true,
numberOfRooms: true,
allowedNumberOfPeople: true,
Expand Down
1 change: 1 addition & 0 deletions src/accommodation/dto/list-of-accommodations.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export class ListOfAccommodationsDto {
id: string;
thumbnailUrl: string;
previewImgUrl: string;
squareMeters: number;
numberOfRooms: number;
allowedNumberOfPeople: number;
Expand Down

0 comments on commit 63a041c

Please sign in to comment.