From f222ee2d51c0c5a7bfe59ee4e2d7acc916e5255f Mon Sep 17 00:00:00 2001
From: L4168 <L4168@student.jamk.fi>
Date: Wed, 26 Jun 2019 16:36:25 +0300
Subject: [PATCH] tasks wip

---
 src/game/game.service.ts    |  2 +-
 src/task/task.controller.ts |  2 +-
 src/task/task.dto.ts        | 12 ++++++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/game/game.service.ts b/src/game/game.service.ts
index 21fcc02..59c7005 100644
--- a/src/game/game.service.ts
+++ b/src/game/game.service.ts
@@ -78,7 +78,7 @@ export class GameService {
     const gameId = await this.gameRepository.save(updatedGame);
 
     // get all the factions that are associated with the game to deny duplicate entries
-    const factions = await this.factionRepository.find(gameId);
+    const factions = await this.factionRepository.find({ game: gameId });
     const factionNames = factions.map(({ factionName }) => factionName);
     // add the factions to db
     if (gameData.factions) {
diff --git a/src/task/task.controller.ts b/src/task/task.controller.ts
index 23c1593..6f272a0 100644
--- a/src/task/task.controller.ts
+++ b/src/task/task.controller.ts
@@ -33,7 +33,7 @@ export class TaskController {
   // creates a new task if the user has admin role in the game
   // :id is the id of the game
   @Post('new-task/:id')
-  @Roles('admin')
+  //@Roles('admin')
   @UsePipes(new ValidationPipe())
   async newTask(@Param('id') id: string, @Body() task: TaskDTO) {
     return this.taskService.newTask(task);
diff --git a/src/task/task.dto.ts b/src/task/task.dto.ts
index 37e4fa5..aa3238f 100644
--- a/src/task/task.dto.ts
+++ b/src/task/task.dto.ts
@@ -1,4 +1,11 @@
-import { IsString, Length, IsNumber, IsBoolean } from 'class-validator';
+import {
+  IsString,
+  Length,
+  IsNumber,
+  IsBoolean,
+  Min,
+  Max,
+} from 'class-validator';
 import { FactionEntity } from 'src/game/faction.entity';
 
 export class TaskDTO {
@@ -9,7 +16,8 @@ export class TaskDTO {
   @Length(0, 255)
   taskDescription: string;
   @IsNumber()
-  @Length(1, 3)
+  @Min(1)
+  @Max(99)
   taskScore: number;
   @IsString()
   @Length(3, 31)
-- 
GitLab