Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
API Toucan
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
Container registry
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
Damien Armillon
API Toucan
Commits
7fe2255e
Commit
7fe2255e
authored
3 years ago
by
Inès Yeterian
Browse files
Options
Downloads
Plain Diff
Merge branch 'lastToucan' into 'master'
Last toucan See merge request
!6
parents
7d01f220
19fff0e0
No related branches found
No related tags found
1 merge request
!6
Last toucan
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/routes/routesToucan.js
+49
-1
49 additions, 1 deletion
backend/routes/routesToucan.js
with
49 additions
and
1 deletion
backend/routes/routesToucan.js
+
49
−
1
View file @
7fe2255e
...
...
@@ -143,7 +143,7 @@ router.get('/pdf/:year/:title', (req, res) => {
var
title
=
req
.
params
.
title
;
var
year
=
parseInt
(
req
.
params
.
year
);
var
nextyear
=
year
+
1
;
var
title
=
new
RegExp
((
title
.
split
(
"
-
"
)).
join
(
"
.
"
));
title
=
new
RegExp
(
'
^
'
+
(
title
.
split
(
"
-
"
)).
join
(
"
.
"
)
+
'
$
'
);
console
.
log
(
title
);
Toucan
.
find
(
...
...
@@ -163,5 +163,53 @@ router.get('/pdf/:year/:title', (req, res) => {
});
});
router
.
get
(
'
/pdf-lastToucan
'
,
(
req
,
res
)
=>
{
Toucan
.
find
()
.
exec
(
function
(
err
,
toucans
){
if
(
err
)
{
res
.
send
(
err
);}
else
{
var
max
=
new
Date
(
toucans
[
0
].
date
);
var
idMax
=
toucans
[
0
].
_id
;
const
nbToucans
=
toucans
.
length
;
var
value
=
toucans
[
0
];
for
(
let
i
=
1
;
i
<
nbToucans
;
i
++
){
value
=
new
Date
(
toucans
[
i
].
date
);
if
(
value
>
max
){
max
=
value
;
idMax
=
toucans
[
i
].
_id
;
}
}
res
.
sendFile
(
path
.
resolve
(
env
.
savedExtensions
[
1
].
path
,
idMax
+
"
.pdf
"
));
}
}
);
});
router
.
get
(
'
/img-lastToucan
'
,
(
req
,
res
)
=>
{
Toucan
.
find
()
.
exec
(
function
(
err
,
toucans
){
if
(
err
)
{
res
.
send
(
err
);}
else
{
var
max
=
new
Date
(
toucans
[
0
].
date
);
var
idMax
=
toucans
[
0
].
_id
;
const
nbToucans
=
toucans
.
length
;
var
value
=
toucans
[
0
];
for
(
let
i
=
1
;
i
<
nbToucans
;
i
++
){
value
=
new
Date
(
toucans
[
i
].
date
);
if
(
value
>
max
){
max
=
value
;
idMax
=
toucans
[
i
].
_id
;
}
}
res
.
redirect
(
'
img/
'
+
idMax
);
}
}
);
});
module
.
exports
=
router
;
\ No newline at end of file
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