#108 added user-task router

parent 7e098957
...@@ -272,6 +272,39 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{ ...@@ -272,6 +272,39 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
/**check other users tasks that are related to the user through common projects, by user token*/
router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Response>=>{
const {user} = req.body
const projects = await dataSource
.getRepository(Project)
.find(
{ relations:{
members:true,
tasks:{
author:true,
executor:true
}
},
where:{
members:{
user:{
id:user.id
}
}
}})
if (!projects) return res.status(404).send({Message:'projects not found'})
let tasks:Task[] = []
if (projects.length>0) {
for (let project of projects){
if (project?.tasks) {
tasks=tasks.concat(project.tasks)
}
}
}
return res.send({projects, tasks})
})
export default router; export default router;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment