From 01270b1f0c0ccfd9118ff3797d375ded92f86136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Iv=C3=A1n?= <80365304+Diego-lvan@users.noreply.github.com> Date: Sun, 29 Sep 2024 21:20:49 -0600 Subject: [PATCH 1/2] regresando ruta creada --- backend/src/route/route.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/route/route.service.ts b/backend/src/route/route.service.ts index b4acebdc..baf2dd22 100644 --- a/backend/src/route/route.service.ts +++ b/backend/src/route/route.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { InjectDataSource, InjectRepository } from '@nestjs/typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; import { Route, RouteStatus } from './entities/route.entity'; -import { DataSource, Repository } from 'typeorm'; +import { MoreThan, Repository } from 'typeorm'; import { User } from 'src/user/entities/user.entity'; import { Town } from 'src/town/entities/town.entity'; import { TravelPlaceService } from 'src/travel-place/travel-place.service'; @@ -23,7 +23,6 @@ export class RouteService { @InjectRepository(User) private userRepository: Repository, @InjectRepository(Town) private townRepository: Repository, private readonly travelPlaceService: TravelPlaceService, - @InjectDataSource() private dataSource: DataSource, private readonly placeService: PlaceService, private readonly visitedService: VisitedService, private readonly userService: UserService, @@ -87,12 +86,14 @@ export class RouteService { await this.travelPlaceService.create(createTravelPlace); } + + return await this.getRouteById(idRoute, email); } async getRouteAndPlacesByUser(email: string, routeStatus: RouteStatus) { const res = await this.routeRepository.find({ relations: ['travelPlace'], - where: { user: { email }, status: routeStatus }, + where: { user: { email }, status: routeStatus, endDate: MoreThan(new Date()) }, }); return res; -- GitLab From 8685ee8ed7e2096b1792f6f2210ec4c41578f235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Iv=C3=A1n?= <80365304+Diego-lvan@users.noreply.github.com> Date: Sun, 29 Sep 2024 21:21:03 -0600 Subject: [PATCH 2/2] regresando ruta creada --- backend/src/route/route.controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/route/route.controller.ts b/backend/src/route/route.controller.ts index 7586762f..54de3b40 100644 --- a/backend/src/route/route.controller.ts +++ b/backend/src/route/route.controller.ts @@ -38,7 +38,7 @@ export class RouteController { @ApiQuery({ name: 'routeStatus', type: String, schema: { enum: Object.values(RouteStatus) } }) @ApiBearerAuth('jwt') @UseGuards(AuthUserGuard) - async recommendRouteGet(@Req() req: CustomUserRequest, @Query('routeStatus') routeStatus: RouteStatus) { + async getRecommendRoute(@Req() req: CustomUserRequest, @Query('routeStatus') routeStatus: RouteStatus) { const { email } = req.user; return await this.routeService.getRouteAndPlacesByUser(email, routeStatus); } @@ -54,7 +54,7 @@ export class RouteController { @Patch('/:idRoute') @ApiParam({ name: 'idRoute', type: Number }) - @ApiBody({ type: UpdateRouteStatusDto, description: 'accepted, rejected, pending' }) + @ApiBody({ type: UpdateRouteStatusDto, description: 'accepted, pending' }) @ApiBearerAuth('jwt') @UseGuards(AuthUserGuard) async updateRoute(@Body() updateRouteStatusDto: UpdateRouteStatusDto, @Param('idRoute') idRoute: number) { -- GitLab