Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WIE_202021_CSBillero11
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bernard Roland (Student Com20)
WIE_202021_CSBillero11
Commits
9400af94
Commit
9400af94
authored
3 years ago
by
Bernard Roland (Student Com20)
Browse files
Options
Downloads
Patches
Plain Diff
Added a expected time to a user assignment
parent
8ccad7a5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/migrations/0000_initial.ts
+1
-0
1 addition, 0 deletions
server/migrations/0000_initial.ts
server/src/v1/task.ts
+25
-11
25 additions, 11 deletions
server/src/v1/task.ts
server/src/v1/team.ts
+2
-0
2 additions, 0 deletions
server/src/v1/team.ts
with
28 additions
and
11 deletions
server/migrations/0000_initial.ts
+
1
−
0
View file @
9400af94
...
...
@@ -62,6 +62,7 @@ export async function up(database: Knex): Promise<void> {
table
.
uuid
(
'
user_id
'
).
notNullable
().
references
(
'
users.id
'
);
table
.
uuid
(
'
task_id
'
).
notNullable
().
references
(
'
tasks.id
'
);
table
.
primary
([
'
user_id
'
,
'
task_id
'
]);
table
.
integer
(
'
time
'
).
notNullable
();
})
.
createTable
(
'
comments
'
,
table
=>
{
table
.
uuid
(
'
id
'
).
notNullable
().
primary
();
...
...
This diff is collapsed.
Click to expand it.
server/src/v1/task.ts
+
25
−
11
View file @
9400af94
...
...
@@ -23,6 +23,7 @@ task.get('/:uuid', async (req, res) => {
project
:
'
tasks.project_id
'
,
name
:
'
tasks.name
'
,
text
:
'
tasks.text
'
,
icon
:
'
tasks.icon
'
,
status
:
'
tasks.status
'
,
priority
:
'
tasks.priority
'
,
created
:
'
tasks.created
'
,
...
...
@@ -35,7 +36,8 @@ task.get('/:uuid', async (req, res) => {
if
(
task
.
length
>=
1
)
{
const
assigned
=
await
database
(
'
task_assignees
'
)
.
select
({
id
:
'
task_assignees.user_id
'
,
user
:
'
task_assignees.user_id
'
,
time
:
'
task_assignees.time
'
,
})
.
where
({
'
task_assignees.task_id
'
:
id
,
...
...
@@ -59,7 +61,10 @@ task.get('/:uuid', async (req, res) => {
status
:
'
success
'
,
task
:
{
...
task
[
0
],
assigned
:
assigned
.
map
(
row
=>
row
.
id
),
assigned
:
assigned
.
map
(
row
=>
({
user
:
row
.
user
,
time
:
row
.
time
,
})),
dependentcies
:
dependentcies
.
map
(
row
=>
row
.
id
),
requirements
:
requirements
.
map
(
row
=>
({
role
:
row
.
role
,
...
...
@@ -92,6 +97,11 @@ interface TaskRequirement {
time
:
number
;
}
interface
TaskAssignment
{
user
:
string
;
time
:
number
;
}
interface
AddTaskBody
{
project
:
string
;
name
:
string
;
...
...
@@ -100,7 +110,7 @@ interface AddTaskBody {
priority
:
string
;
dependentcies
:
Array
<
string
>
;
requirements
:
Array
<
TaskRequirement
>
;
assigned
:
Array
<
string
>
;
assigned
:
Array
<
TaskAssignment
>
;
token
:
Token
;
}
...
...
@@ -112,7 +122,8 @@ task.post('/', async (req, res) => {
try
{
const
project_id
=
req
.
body
.
project
;
const
dependentcy_ids
=
req
.
body
.
dependentcies
;
const
assigned_ids
=
req
.
body
.
assigned
;
const
assigned
=
req
.
body
.
assigned
;
const
assigned_ids
=
assigned
.
map
(
asg
=>
asg
.
user
);
const
requirements
=
req
.
body
.
requirements
;
const
requirement_ids
=
requirements
.
map
(
req
=>
req
.
role
);
for
(
const
team_id
of
[
...
dependentcy_ids
,
...
requirement_ids
,
...
assigned_ids
,
project_id
])
{
...
...
@@ -166,9 +177,10 @@ task.post('/', async (req, res) => {
}
if
(
assigned_ids
.
length
!==
0
)
{
await
transaction
(
'
task_assignees
'
).
insert
(
assigned
_ids
.
map
(
user_i
d
=>
({
assigned
.
map
(
assigne
d
=>
({
task_id
:
task_id
,
user_id
:
user_id
,
user_id
:
assigned
.
user
,
time
:
assigned
.
time
,
}))
);
}
...
...
@@ -208,7 +220,7 @@ interface UpdateTaskBody {
remove_assigned
?:
Array
<
string
>
;
add_dependentcies
?:
Array
<
string
>
;
add_requirements
?:
Array
<
TaskRequirement
>
;
add_assigned
?:
Array
<
string
>
;
add_assigned
?:
Array
<
TaskAssignment
>
;
token
:
Token
;
}
...
...
@@ -220,7 +232,8 @@ task.put('/:uuid', async (req, res) => {
const
remove_assigned_ids
=
req
.
body
.
remove_assigned
??
[];
const
remove_requirement_ids
=
req
.
body
.
remove_requirements
??
[];
const
add_dependentcy_ids
=
req
.
body
.
add_dependentcies
??
[];
const
add_assigned_ids
=
req
.
body
.
add_assigned
??
[];
const
add_assigned
=
req
.
body
.
add_assigned
??
[];
const
add_assigned_ids
=
add_assigned
.
map
(
asg
=>
asg
.
user
);
const
add_requirements
=
req
.
body
.
add_requirements
??
[];
const
add_requirement_ids
=
add_requirements
.
map
(
req
=>
req
.
role
);
const
all_ids
=
[
...
...
@@ -305,11 +318,12 @@ task.put('/:uuid', async (req, res) => {
}))
);
}
if
(
add_assigned
_ids
.
length
!==
0
)
{
if
(
add_assigned
.
length
!==
0
)
{
await
transaction
(
'
task_assignees
'
).
insert
(
add_assigned
_ids
.
map
(
user_i
d
=>
({
add_assigned
.
map
(
assigne
d
=>
({
task_id
:
task_id
,
user_id
:
user_id
,
user_id
:
assigned
.
user
,
time
:
assigned
.
time
,
}))
);
}
...
...
This diff is collapsed.
Click to expand it.
server/src/v1/team.ts
+
2
−
0
View file @
9400af94
...
...
@@ -70,6 +70,7 @@ team.get('/', async (req, res) => {
.
select
({
id
:
'
teams.id
'
,
name
:
'
teams.name
'
,
role
:
'
team_members.role_id
'
})
.
where
({
'
users.id
'
:
req
.
body
.
token
.
id
...
...
@@ -96,6 +97,7 @@ team.get('/:uuid/', async (req, res) => {
.
select
({
id
:
'
teams.id
'
,
name
:
'
teams.name
'
,
role
:
'
team_members.role_id
'
,
})
.
where
({
'
users.id
'
:
req
.
body
.
token
.
id
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment