Skip to content
Snippets Groups Projects
Commit 85d4d7e0 authored by Bernard Roland (Student Com20)'s avatar Bernard Roland (Student Com20)
Browse files

Added a querry to get all assigned users of a task

parent 7d9a20ed
No related branches found
No related tags found
No related merge requests found
......@@ -301,6 +301,45 @@ task.get('/:uuid/work', async (req, res) => {
}
});
task.get('/:uuid/assigned', async (req, res) => {
try {
const id = req.params.uuid;
if (validate(id)) {
const users = await database('team_members')
.innerJoin('team_projects', 'team_members.team_id', 'team_projects.team_id')
.innerJoin('tasks', 'team_projects.project_id', 'tasks.project_id')
.innerJoin('task_assignees', 'tasks.id', 'task_assignees.task_id')
.innerJoin('users', 'task_assignees.user_id', 'users.id')
.select({
id: 'users.id',
username: 'users.user_name',
email: 'users.email',
realname: 'users.real_name',
})
.sum({ time: 'task_assignees.time' })
.where({
'team_members.user_id': req.body.token.id,
'tasks.id': id,
})
.groupBy('users.id');
res.status(200).json({
status: 'success',
assigned: users,
});
} else {
res.status(400).json({
status: 'error',
message: 'malformed uuid',
});
}
} catch (e) {
res.status(400).json({
status: 'error',
message: 'failed to get assignees',
});
}
});
task.get('/:uuid', async (req, res) => {
try {
const id = req.params.uuid;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment