diff --git a/backend/src/route/route.service.ts b/backend/src/route/route.service.ts index e624089e3888f1ac7972d94eeb6dd4e1c338b70a..1b2cd86a6870924e56628518e0cf352204392233 100644 --- a/backend/src/route/route.service.ts +++ b/backend/src/route/route.service.ts @@ -72,5 +72,6 @@ export class RouteService { for (const place of placesChooen) { await this.createRoute(email, idTown, place.idPlace, new Date(), new Date()); } + return placesChooen; } } diff --git a/backend/src/visited/entities/visited.entity.ts b/backend/src/visited/entities/visited.entity.ts index 81de0fedb2cc903d4532f3139814ba3dc228676c..2ed305b32fbe99372717cc819aefb9dab52609d8 100644 --- a/backend/src/visited/entities/visited.entity.ts +++ b/backend/src/visited/entities/visited.entity.ts @@ -1,15 +1,16 @@ import { Place } from 'src/place/entities/place.entity'; import { User } from 'src/user/entities/user.entity'; -import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm'; +import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; @Entity() export class Visited { - @PrimaryColumn() + @PrimaryGeneratedColumn() + idVisited: number; + @ManyToOne(() => Place, (place) => place.idPlace, { eager: true }) @JoinColumn({ name: 'place' }) place: Place; - @PrimaryColumn() @ManyToOne(() => User, (user) => user.email) @JoinColumn({ name: 'user' }) user: User; diff --git a/backend/src/visited/visited.service.ts b/backend/src/visited/visited.service.ts index 722905b5c3c3aa54891dd84bff983921a7ddb2ac..dbe0fa9ec38354224044106f28a8897aacd97af8 100644 --- a/backend/src/visited/visited.service.ts +++ b/backend/src/visited/visited.service.ts @@ -21,15 +21,12 @@ export class VisitedService { const user: User = await this.userService.findOne(email); if (!place || !user) throw new BadRequestException('Place or user not found'); - await this.visitedRepository.upsert( - { place, user, rating: createVisitedDto.rating }, - { conflictPaths: ['place', 'user'] }, - ); + await this.visitedRepository.save({ place, user, rating: createVisitedDto.rating }); } async getVisitedByUser(email: string): Promise { const user: User = await this.userService.findOne(email); - return this.visitedRepository.find({ + return await this.visitedRepository.find({ where: { user }, relations: ['place', 'place.categories'], });