Skip to content

Commit

Permalink
Feature/list tasks basedon sprint or project (#16)
Browse files Browse the repository at this point in the history
* Backend data

* axios api refactor

* find tasks by sprint or project
  • Loading branch information
DankaMarci authored Oct 11, 2024
1 parent b434e44 commit 62c80f9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/backend/src/tasks/tasks.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export class TasksController {
return this.tasksService.findAll();
}

@Get('sprint/:sprintId')
findAllBySprintId(@Param('sprintId') sprintId: string) {
return this.tasksService.findAllBySprintId(Number(sprintId));
}

@Get('project/:projectId')
findAllByProjectId(@Param('projectId') projectId: string) {
return this.tasksService.findAllByProjectId(Number(projectId));
}

@Get(':id')
findOne(@Param('id') id: string) {
return this.tasksService.findOne(Number(id));
Expand Down
24 changes: 24 additions & 0 deletions apps/backend/src/tasks/tasks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ export class TasksService {
}
}

async findAllBySprintId(sprintId: number) {
try {
return await this.prisma.tasks.findMany({
where: {
sprintId,
},
});
} catch {
throw new NotFoundException('Tasks not found');
}
}

async findAllByProjectId(projectId: number) {
try {
return await this.prisma.tasks.findMany({
where: {
projectId,
},
});
} catch {
throw new NotFoundException('Tasks not found');
}
}

async findOne(id: number) {
const task = await this.prisma.tasks.findUnique({
where: { id },
Expand Down

0 comments on commit 62c80f9

Please sign in to comment.