Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IcarusServer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
icarus
IcarusServer
Commits
79a8f4c6
Commit
79a8f4c6
authored
Dec 18, 2015
by
andreagerino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added finer timestamp management
parent
87684f5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
1 deletion
+39
-1
storage.js
routes/storage.js
+39
-1
No files found.
routes/storage.js
View file @
79a8f4c6
...
...
@@ -8,7 +8,7 @@ var ObjectID = require('mongodb').ObjectID;
var
assert
=
assert
=
require
(
'assert'
);
// Connection URL
var
mongoUrl
=
'mongodb://icarus:icarus@
localhos
t:27017/icarus'
;
var
mongoUrl
=
'mongodb://icarus:icarus@
webdev.ewlab.di.unimi.i
t:27017/icarus'
;
//Connect to the server and intialise the pool
var
icarusDb
;
...
...
@@ -58,6 +58,14 @@ router.post('/', function(req, res, next){
if
(
Object
.
keys
(
resource
).
length
>
0
)
{
var
timestampContainer
=
getTimestampContainer
(
resource
);
if
(
timestampContainer
!=
undefined
){
preprocessTimestampContainer
(
timestampContainer
);
}
collection
.
insertOne
(
resource
,
function
(
err
,
r
)
{
if
(
err
!=
null
)
{
...
...
@@ -86,4 +94,34 @@ router.post('/', function(req, res, next){
});
function
getTimestampContainer
(
arg
){
if
(
arg
[
'timestamp'
]
!=
undefined
&&
(
arg
[
'timestamp'
][
'utc'
]
!=
undefined
)
||
arg
[
'timestamp'
][
'user'
]
!=
undefined
)
return
arg
[
'timestamp'
];
return
undefined
;
}
function
preprocessTimestampContainer
(
container
){
var
utcSeconds
=
container
[
'utc'
];
var
userSeconds
=
container
[
'user'
];
if
(
utcSeconds
!=
undefined
){
var
utcMsec
=
utcSeconds
*
1000
;
container
[
'utc'
]
=
new
Date
(
utcMsec
);
}
if
(
userSeconds
!=
undefined
){
var
userMsec
=
userSeconds
*
1000
;
container
[
'user'
]
=
new
Date
(
userMsec
);
}
}
module
.
exports
=
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