Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
form-creator-api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
simmctic
form-creator
form-creator-api
Commits
58482412
Commit
58482412
authored
5 years ago
by
Stephanie Briere Americo
Browse files
Options
Downloads
Plain Diff
Merge branch 'issue/75' into 'develop'
Issue
#75
: Fix route to list forms See merge request
!75
parents
a6cc08e9
20fd9532
Branches
Branches containing commit
No related tags found
1 merge request
!75
Issue #75: Fix route to list forms
Pipeline
#23266
passed
5 years ago
Stage: test
Stage: build
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+7
-0
7 additions, 0 deletions
CHANGELOG.md
package.json
+1
-1
1 addition, 1 deletion
package.json
src/api/controllers/user.spec.ts
+49
-49
49 additions, 49 deletions
src/api/controllers/user.spec.ts
src/api/controllers/user.ts
+111
-57
111 additions, 57 deletions
src/api/controllers/user.ts
with
168 additions
and
107 deletions
CHANGELOG.md
+
7
−
0
View file @
58482412
...
...
@@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[
Semantic Versioning
](
https://semver.org/spec/v2.0.0.html
)
.
## 1.2.5 - 02/06/2020
## Changed
-
Route to list forms now returns all the dates and answers of the forms #75 (Richard Heise)
-
Added two extras steps on route waterfall using eachSeries.
-
Tests weren't changed since the steps where tested by themselfs in other routes.
## 1.2.4 - 01/06/2020
## Added
-
Created route to get modified dates of a form #76 (Richard Heise)
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
58482412
{
"name"
:
"form-creator-api"
,
"version"
:
"1.2.
4
"
,
"version"
:
"1.2.
5
"
,
"description"
:
"RESTful API used to manage and answer forms."
,
"main"
:
"index.js"
,
"scripts"
:
{
...
...
This diff is collapsed.
Click to expand it.
src/api/controllers/user.spec.ts
+
49
−
49
View file @
58482412
This diff is collapsed.
Click to expand it.
src/api/controllers/user.ts
+
111
−
57
View file @
58482412
...
...
@@ -23,10 +23,11 @@ import { User } from "../../core/user";
import
{
Response
,
NextFunction
}
from
"
express
"
;
import
{
Request
}
from
"
../apiTypes
"
;
import
{
OptHandler
}
from
"
../../utils/optHandler
"
;
import
{
waterfall
}
from
"
async
"
;
import
{
eachSeries
,
map
,
waterfall
}
from
"
async
"
;
import
*
as
bcrypt
from
"
bcrypt
"
;
import
*
as
jwt
from
"
jsonwebtoken
"
;
import
{
Form
}
from
"
../../core/form
"
;
import
{
FormAnswer
,
FormAnswerOptions
}
from
"
../../core/formAnswer
"
;
export
class
UserCtrl
{
...
...
@@ -231,6 +232,8 @@ export class UserCtrl {
public
static
listForms
(
req
:
Request
,
res
:
Response
,
next
:
NextFunction
)
{
waterfall
([
(
callback
:
(
err
:
Error
,
forms
?:
any
[])
=>
void
)
=>
{
req
.
db
.
form
.
list
(
req
.
params
.
id
,
(
err
:
Error
,
forms
?:
Form
[])
=>
{
if
(
err
)
{
res
.
status
(
500
).
json
({
...
...
@@ -244,11 +247,62 @@ export class UserCtrl {
id
:
form
.
id
,
title
:
form
.
title
,
description
:
form
.
description
,
answersNumber
:
0
,
date
:
""
}));
res
.
json
(
mappedForms
);
callback
(
null
,
mappedForms
);
});
},
(
forms
:
any
[],
callback
:
(
err
:
Error
,
result
?:
Object
[])
=>
void
)
=>
{
eachSeries
(
forms
,
(
form
:
any
,
innerCallback
)
=>
{
req
.
db
.
answer
.
readAll
(
form
.
id
,
(
err
:
Error
,
resultAnswer
?:
FormAnswer
[])
=>
{
if
(
err
)
{
innerCallback
(
err
);
return
;
}
let
sum
:
number
=
0
;
for
(
const
forms
of
resultAnswer
)
{
sum
+=
Object
.
keys
(
forms
.
inputAnswers
).
length
}
form
.
answersNumber
=
sum
;
innerCallback
(
null
);
});
},
(
e
)
=>
{
callback
(
e
,
forms
);
});
},
(
forms
:
any
[],
callback
:
(
err
:
Error
,
result
?:
Object
[])
=>
void
)
=>
{
eachSeries
(
forms
,
(
form
:
any
,
innerCallback
)
=>
{
req
.
db
.
form
.
readDate
(
form
.
id
,
(
err
:
Error
,
dates
?:
any
[])
=>
{
if
(
err
)
{
innerCallback
(
err
);
return
;
}
if
(
dates
.
length
)
{
form
.
date
=
dates
.
sort
().
slice
(
-
1
)[
0
].
update_date
;
}
innerCallback
(
null
);
});
},
(
e
)
=>
{
callback
(
e
,
forms
);
});
},
],
(
error
:
Error
,
forms
)
=>
{
if
(
error
)
{
res
.
status
(
500
).
json
({
message
:
"
Some error has ocurred. Check error property for details.
"
,
error
:
error
.
message
});
return
;
}
res
.
json
(
forms
);
});
}
public
static
update
(
req
:
Request
,
res
:
Response
,
next
:
NextFunction
)
{
...
...
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