Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
251b2975
Commit
251b2975
authored
Feb 27, 2023
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#167
added week-data-start to router/tasks
parent
dffb6345
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
projects.ts
planner-api/src/routers/projects.ts
+1
-0
tasks.ts
planner-api/src/routers/tasks.ts
+65
-0
users.ts
planner-api/src/routers/users.ts
+1
-0
No files found.
planner-api/src/routers/projects.ts
View file @
251b2975
...
...
@@ -47,6 +47,7 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
.
leftJoinAndSelect
(
'member.user'
,
'user'
)
.
where
(
'project.id IN(:...projectIds)'
,
{
projectIds
})
.
getMany
()
console
.
log
(
'projects
\
n'
,
projects
)
return
res
.
send
({
projects
})
}
catch
(
e
)
{
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
...
...
planner-api/src/routers/tasks.ts
View file @
251b2975
...
...
@@ -133,6 +133,7 @@ router.get('/user/:userId', async (req: Request, res: Response):Promise<Response
id
:
userId
}},
})
console
.
log
(
'tasks
\
n'
,
tasks
)
return
res
.
send
({
tasks
})
}
catch
(
e
){
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
...
...
@@ -395,4 +396,68 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
})
/**router GET "/week-data-start/{userId}` which receives user through req.body.user,
* returns list of Task related to the userId,
* object with key displayName related to userId, list of Project related to user
*/
router
.
get
(
'/week-data-start/:userId'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
userId
}
=
req
.
params
try
{
const
requesterUser
=
req
.
body
.
user
const
user
=
await
dataSource
.
getRepository
(
User
)
.
findOne
({
relations
:{
members
:
true
},
where
:{
id
:
userId
}
})
if
(
!
user
)
return
res
.
status
(
404
).
send
({
Message
:
'user not found'
})
const
projects
=
await
dataSource
.
getRepository
(
Project
)
.
find
({
relations
:{
members
:
true
},
where
:{
members
:{
user
:{
id
:
requesterUser
.
id
}
}
}
})
if
(
!
projects
)
return
res
.
status
(
404
).
send
({
Message
:
'projects not found'
})
const
projectIds
=
projects
.
map
(
project
=>
{
return
project
.
id
})
const
tasks
=
await
dataSource
.
getRepository
(
Task
)
.
find
({
relations
:{
project
:
true
,
},
where
:{
project
:{
id
:
In
(
projectIds
)
}
}
})
const
{
displayName
}
=
user
if
(
!
tasks
)
return
res
.
status
(
404
).
send
({
Message
:
'tasks not found'
})
console
.
log
(
'tasks: '
,
tasks
,
"projects"
,
projects
,
'displayName'
,
displayName
)
return
res
.
send
({
displayName
,
projects
,
tasks
})
}
catch
(
e
){
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
}
})
export
default
router
;
planner-api/src/routers/users.ts
View file @
251b2975
...
...
@@ -51,6 +51,7 @@ return res.send({users})
.
where
(
"user.id = :userId"
,
{
userId
})
.
getOne
()
if
(
!
displayName
)
return
res
.
status
(
404
).
send
({
message
:
'displayName not found'
})
console
.
log
(
'displayName
\
n'
,
displayName
)
return
res
.
send
(
displayName
)
}
catch
(
e
)
{
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment