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
2503a13e
Commit
2503a13e
authored
Feb 22, 2023
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#167
remove unused requests to db in routers/tasks.ts
parent
ac8ddb62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
53 deletions
+5
-53
tasks.ts
planner-api/src/routers/tasks.ts
+5
-53
No files found.
planner-api/src/routers/tasks.ts
View file @
2503a13e
...
...
@@ -40,23 +40,6 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
newTask
.
title
=
title
;
newTask
.
description
=
description
;
if
(
project
)
{
const
watcherOfProject
=
await
dataSource
.
getRepository
(
Project
)
.
findOne
({
relations
:{
members
:
true
,
},
where
:
{
id
:
project
.
id
,
members
:
{
user
:{
id
:
user
.
id
},
roleProject
:
MemberRole
.
WATCHER
,
},
}
})
if
(
watcherOfProject
)
return
res
.
send
({
message
:
"watcher could nt make tasks"
})
newTask
.
project
=
project
;
}
else
{
const
personalProject
=
await
dataSource
...
...
@@ -71,14 +54,9 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
})
if
(
personalProject
)
newTask
.
project
=
personalProject
;
}
newTask
.
dateTimeDeadLine
=
dateTimeDeadlineFinal
;
newTask
.
author
=
user
;
if
(
newTask
.
project
.
title
===
"Личные дела"
){
newTask
.
executor
=
user
;
}
else
{
newTask
.
executor
=
executor
;
}
newTask
.
project
.
title
===
"Личные дела"
?
newTask
.
executor
=
user
:
newTask
.
executor
=
executor
;
newTask
.
priority
=
priority
;
await
newTask
.
save
();
if
(
calendar
)
{
...
...
@@ -104,23 +82,6 @@ router.post('/users', auth, async(req:Request, res:Response):Promise<Response>=>
newTask
.
title
=
title
;
newTask
.
description
=
description
;
if
(
project
)
{
const
watcherOfProject
=
await
dataSource
.
getRepository
(
Project
)
.
findOne
({
relations
:{
members
:
true
,
},
where
:
{
id
:
project
.
id
,
members
:
{
user
:{
id
:
user
.
id
},
roleProject
:
MemberRole
.
WATCHER
,
},
}
})
if
(
watcherOfProject
)
return
res
.
send
({
message
:
"watcher could nt make tasks"
})
newTask
.
project
=
project
;
}
else
{
const
personalProject
=
await
dataSource
...
...
@@ -396,19 +357,15 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
tasks
:{
author
:
true
,
executor
:
true
}
},
}},
where
:{
members
:{
roleProject
:
Not
(
Equal
(
MemberRole
.
WATCHER
)),
user
:{
id
:
user
.
id
},
project
:{
title
:
Not
(
Equal
(
"Личные дела"
))
}
}
}})
}}}})
if
(
!
projectsWithTasks
)
return
res
.
status
(
404
).
send
({
Message
:
'projects not found'
})
let
tasks
:
Task
[]
=
[]
...
...
@@ -416,10 +373,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
for
(
const
project
of
projectsWithTasks
){
if
(
project
?.
tasks
)
{
tasks
=
tasks
.
concat
(
project
.
tasks
)
}
}
}
}}}
const
projectIds
=
projectsWithTasks
.
map
(
project
=>
{
return
project
.
id
})
const
projects
=
await
dataSource
.
getRepository
(
Project
)
...
...
@@ -432,9 +386,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
id
:
In
(
projectIds
),
members
:{
roleProject
:
Not
(
MemberRole
.
WATCHER
)
}
},
})
}},})
return
res
.
send
({
projects
,
tasks
})
}
catch
(
e
){
console
.
log
(
'Error: '
,(
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