Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tracemob
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
POCS
cozy
tracemob
Commits
0564a338
Commit
0564a338
authored
4 years ago
by
paultranvan
Browse files
Options
Downloads
Plain Diff
Merge branch 'release-1.1.0'
parents
5eb606ba
ef1e76b4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/trace-requests.js
+31
-16
31 additions, 16 deletions
src/trace-requests.js
with
31 additions
and
16 deletions
src/trace-requests.js
+
31
−
16
View file @
0564a338
const
BASE_URL
=
'
https://trace.grfmap.com:8081
'
const
BASE_URL
=
'
https://trace.grfmap.com:8081
'
const
{
requestFactory
}
=
require
(
'
cozy-konnector-libs
'
)
const
{
log
,
errors
,
requestFactory
}
=
require
(
'
cozy-konnector-libs
'
)
const
request
=
requestFactory
({
const
request
=
requestFactory
({
cheerio
:
false
,
cheerio
:
false
,
...
@@ -18,7 +18,10 @@ const getFirstAndLastTripTimestamp = async function(token) {
...
@@ -18,7 +18,10 @@ const getFirstAndLastTripTimestamp = async function(token) {
const
body
=
{
const
body
=
{
user
:
token
user
:
token
}
}
return
request
(
path
,
{
method
:
'
POST
'
,
body
})
return
request
(
path
,
{
method
:
'
POST
'
,
body
}).
catch
(
err
=>
{
log
(
'
info
'
,
err
&&
err
.
message
)
throw
new
Error
(
errors
.
VENDOR_DOWN
)
})
}
}
/**
/**
...
@@ -36,17 +39,23 @@ const getServerCollectionFromDate = async function(
...
@@ -36,17 +39,23 @@ const getServerCollectionFromDate = async function(
collection
,
collection
,
{
excludeFirst
=
true
}
=
{}
{
excludeFirst
=
true
}
=
{}
)
{
)
{
// Note the expected timestamp is in seconds
let
results
const
startTime
=
new
Date
(
startDate
).
getTime
()
/
1000
try
{
const
endTime
=
Date
.
now
()
/
1000
// Note the expected timestamp is in seconds
const
body
=
{
const
startTime
=
new
Date
(
startDate
).
getTime
()
/
1000
user
:
token
,
const
endTime
=
Date
.
now
()
/
1000
start_time
:
startTime
,
const
body
=
{
end_time
:
endTime
,
user
:
token
,
key_list
:
[
collection
]
start_time
:
startTime
,
end_time
:
endTime
,
key_list
:
[
collection
]
}
const
path
=
`
${
BASE_URL
}
/datastreams/find_entries/timestamp`
results
=
await
request
(
path
,
{
method
:
'
POST
'
,
body
})
}
catch
(
err
)
{
log
(
'
info
'
,
err
&&
err
.
message
)
throw
new
Error
(
errors
.
VENDOR_DOWN
)
}
}
const
path
=
`
${
BASE_URL
}
/datastreams/find_entries/timestamp`
const
results
=
await
request
(
path
,
{
method
:
'
POST
'
,
body
})
return
excludeFirst
?
results
.
phone_data
.
slice
(
1
)
:
results
.
phone_data
return
excludeFirst
?
results
.
phone_data
.
slice
(
1
)
:
results
.
phone_data
}
}
...
@@ -58,11 +67,17 @@ const getServerCollectionFromDate = async function(
...
@@ -58,11 +67,17 @@ const getServerCollectionFromDate = async function(
* @returns {object} - The full trips for this day
* @returns {object} - The full trips for this day
*/
*/
const
getTripsForDay
=
async
function
(
token
,
day
)
{
const
getTripsForDay
=
async
function
(
token
,
day
)
{
const
path
=
`
${
BASE_URL
}
/timeline/getTrips/
${
day
}
`
let
trips
const
body
=
{
try
{
user
:
token
const
path
=
`
${
BASE_URL
}
/timeline/getTrips/
${
day
}
`
const
body
=
{
user
:
token
}
trips
=
await
request
(
path
,
{
method
:
'
POST
'
,
body
})
}
catch
(
err
)
{
log
(
'
info
'
,
err
&&
err
.
message
)
throw
new
Error
(
errors
.
VENDOR_DOWN
)
}
}
const
trips
=
await
request
(
path
,
{
method
:
'
POST
'
,
body
})
return
trips
.
timeline
return
trips
.
timeline
}
}
...
...
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