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
caec72a3
Commit
caec72a3
authored
Nov 15, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#45
fix of projects fixtures and task model
parent
50266906
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
23 deletions
+23
-23
fixtures.ts
planner-api/src/fixtures.ts
+17
-12
Project.ts
planner-api/src/models/Project.ts
+1
-8
Task.ts
planner-api/src/models/Task.ts
+2
-2
tasks.ts
planner-api/src/routers/tasks.ts
+3
-1
No files found.
planner-api/src/fixtures.ts
View file @
caec72a3
...
@@ -39,16 +39,7 @@ const loadFixtures = async () => {
...
@@ -39,16 +39,7 @@ const loadFixtures = async () => {
await
user
.
save
();
await
user
.
save
();
users
.
push
(
user
)
users
.
push
(
user
)
}
}
const
projects
:
Project
[]
=
[]
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
const
newProject
=
new
Project
();
newProject
.
title
=
`Project
${
faker
.
random
.
words
(
1
)}
`
;
newProject
.
color
=
faker
.
random
.
words
(
4
);
newProject
.
admin
=
faker
.
helpers
.
arrayElement
(
users
);
newProject
.
workers
=
faker
.
helpers
.
arrayElements
(
users
,
randomIntFromInterval
(
1
,
3
));
await
newProject
.
save
();
projects
.
push
(
newProject
)
}
const
tasks
:
Task
[]
=
[]
const
tasks
:
Task
[]
=
[]
type
taskFinishType
=
"opened"
|
"done"
|
"failed"
;
type
taskFinishType
=
"opened"
|
"done"
|
"failed"
;
type
priorityType
=
"A"
|
"B"
|
"C"
;
type
priorityType
=
"A"
|
"B"
|
"C"
;
...
@@ -63,7 +54,6 @@ const loadFixtures = async () => {
...
@@ -63,7 +54,6 @@ const loadFixtures = async () => {
newTask
.
dateTimeDue
=
faker
.
date
.
soon
(
randomIntFromInterval
(
1
,
15
));
newTask
.
dateTimeDue
=
faker
.
date
.
soon
(
randomIntFromInterval
(
1
,
15
));
newTask
.
dateTimeStart
=
faker
.
date
.
recent
((
randomIntFromInterval
(
0
,
8
)));
newTask
.
dateTimeStart
=
faker
.
date
.
recent
((
randomIntFromInterval
(
0
,
8
)));
newTask
.
author
=
faker
.
helpers
.
arrayElement
(
users
);
newTask
.
author
=
faker
.
helpers
.
arrayElement
(
users
);
newTask
.
project
=
faker
.
helpers
.
arrayElement
(
projects
);
newTask
.
accomplish
=
faker
.
helpers
.
arrayElement
(
accomplish
);
newTask
.
accomplish
=
faker
.
helpers
.
arrayElement
(
accomplish
);
newTask
.
priority
=
faker
.
helpers
.
arrayElement
(
priorities
);
newTask
.
priority
=
faker
.
helpers
.
arrayElement
(
priorities
);
await
newTask
.
save
();
await
newTask
.
save
();
...
@@ -75,7 +65,6 @@ const loadFixtures = async () => {
...
@@ -75,7 +65,6 @@ const loadFixtures = async () => {
newTask
.
executors
=
faker
.
helpers
.
arrayElements
(
users
,
randomIntFromInterval
(
0
,
3
));
newTask
.
executors
=
faker
.
helpers
.
arrayElements
(
users
,
randomIntFromInterval
(
0
,
3
));
newTask
.
dateTimeDue
=
null
;
newTask
.
dateTimeDue
=
null
;
newTask
.
dateTimeStart
=
null
;
newTask
.
dateTimeStart
=
null
;
newTask
.
project
=
faker
.
helpers
.
arrayElement
(
projects
);
newTask
.
author
=
faker
.
helpers
.
arrayElement
(
users
);
newTask
.
author
=
faker
.
helpers
.
arrayElement
(
users
);
newTask
.
accomplish
=
accomplish
[
0
];
newTask
.
accomplish
=
accomplish
[
0
];
newTask
.
priority
=
faker
.
helpers
.
arrayElement
(
priorities
);
newTask
.
priority
=
faker
.
helpers
.
arrayElement
(
priorities
);
...
@@ -83,6 +72,22 @@ const loadFixtures = async () => {
...
@@ -83,6 +72,22 @@ const loadFixtures = async () => {
tasks
.
push
(
newTask
)
tasks
.
push
(
newTask
)
}
}
}
}
const
projects
:
Project
[]
=
[]
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
const
newProject
=
new
Project
();
newProject
.
title
=
`Project
${
faker
.
random
.
words
(
1
)}
`
;
newProject
.
color
=
faker
.
random
.
words
(
1
);
newProject
.
admin
=
faker
.
helpers
.
arrayElement
(
users
);
newProject
.
tasks
=
faker
.
helpers
.
arrayElements
(
tasks
,
randomIntFromInterval
(
1
,
3
));
newProject
.
workers
=
faker
.
helpers
.
arrayElements
(
users
,
randomIntFromInterval
(
1
,
3
));
await
newProject
.
save
();
projects
.
push
(
newProject
)
}
console
.
log
(
'========================== '
+
'
\
n'
+
'Fixtures done!'
+
'
\
n'
+
'=========================='
)
console
.
log
(
'========================== '
+
'
\
n'
+
'Fixtures done!'
+
'
\
n'
+
'=========================='
)
})
})
...
...
planner-api/src/models/Project.ts
View file @
caec72a3
...
@@ -28,17 +28,10 @@ import {
...
@@ -28,17 +28,10 @@ import {
@
Entity
({
name
:
'Project'
})
@
Entity
({
name
:
'Project'
})
export
class
Project
extends
BaseEntity
implements
IProject
{
export
class
Project
extends
BaseEntity
implements
IProject
{
// data: IncomingData;
// constructor(data:IncomingData){
// super();
// this.data = data
// }
@
PrimaryGeneratedColumn
(
'uuid'
)
@
PrimaryGeneratedColumn
(
'uuid'
)
id
!
:
string
id
!
:
string
// @Column({ name: 'title', type: 'varchar', length:100,nullable: false, default: this.data.title })
// title!: string
@
Column
({
name
:
'title'
,
type
:
'varchar'
,
length
:
100
,
nullable
:
false
})
@
Column
({
name
:
'title'
,
type
:
'varchar'
,
length
:
100
,
nullable
:
false
})
title
!
:
string
title
!
:
string
...
...
planner-api/src/models/Task.ts
View file @
caec72a3
...
@@ -68,6 +68,6 @@ import {
...
@@ -68,6 +68,6 @@ import {
@
JoinTable
()
@
JoinTable
()
executors
!
:
User
[];
executors
!
:
User
[];
@
ManyToOne
(()
=>
Project
,(
project
:{
tasks
:
Task
[]})
=>
project
.
tasks
,{
eager
:
true
,
nullable
:
true
})
@
ManyToOne
(()
=>
Project
,(
project
:{
tasks
:
Task
[]})
=>
project
.
tasks
,{
eager
:
true
,
nullable
:
true
,
onUpdate
:
'CASCADE'
})
project
!
:
Project
|
null
;
project
!
:
Project
;
}
}
planner-api/src/routers/tasks.ts
View file @
caec72a3
...
@@ -12,7 +12,6 @@ router.get('/', async(req:Request, res:Response):Promise<Response> => {
...
@@ -12,7 +12,6 @@ router.get('/', async(req:Request, res:Response):Promise<Response> => {
.
find
()
.
find
()
return
res
.
send
({
tasks
})
return
res
.
send
({
tasks
})
})
})
export
default
router
;
router
.
post
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
router
.
post
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
token
=
req
.
get
(
'Authorization'
);
const
token
=
req
.
get
(
'Authorization'
);
...
@@ -108,3 +107,6 @@ router.put('/',async(req:Request, res:Response)=> {
...
@@ -108,3 +107,6 @@ router.put('/',async(req:Request, res:Response)=> {
await
task
.
save
()
await
task
.
save
()
res
.
send
({
message
:
'update task successfully'
})
res
.
send
({
message
:
'update task successfully'
})
})
})
export
default
router
;
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