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
04e27bb7
Commit
04e27bb7
authored
4 years ago
by
paultranvan
Browse files
Options
Downloads
Patches
Plain Diff
feat: Filter trips by date
parent
9345a6bc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/index.js
+12
-2
12 additions, 2 deletions
src/index.js
with
12 additions
and
2 deletions
src/index.js
+
12
−
2
View file @
04e27bb7
...
...
@@ -82,18 +82,22 @@ async function start(fields) {
log
(
'
info
'
,
`
${
trips
.
length
}
trips to retrieve`
)
let
tripDays
=
{}
const
tripStartDates
=
[]
trips
.
forEach
(
trip
=>
{
const
startTripDate
=
new
Date
(
trip
.
data
.
start_fmt_time
).
toISOString
()
const
day
=
startTripDate
.
split
(
'
T
'
)[
0
]
tripDays
[
day
]
=
true
tripStartDates
.
push
(
trip
.
data
.
start_fmt_time
)
})
let
tripsToSave
=
[]
/* Fetch the actual trips for the relevant days */
let
tripsToSave
=
[]
for
(
const
day
of
Object
.
keys
(
tripDays
))
{
log
(
'
info
'
,
`Fetch trips on
${
day
}
`
)
const
fullTripsForDay
=
await
getTripsForDay
(
userToken
,
day
)
tripsToSave
=
tripsToSave
.
concat
(
fullTripsForDay
)
// The trips need to be filtered, as the day is not precise enough
const
filteredTrips
=
filterTripsByDate
(
fullTripsForDay
,
tripStartDates
)
tripsToSave
=
tripsToSave
.
concat
(
filteredTrips
)
}
/* Save the trips in database */
...
...
@@ -163,6 +167,12 @@ async function start(fields) {
}
}
function
filterTripsByDate
(
trips
,
tripStartDates
)
{
return
trips
.
filter
(
trip
=>
{
return
tripStartDates
.
includes
(
trip
.
properties
.
start_fmt_time
)
})
}
async
function
getFirstAndLastTripTimestamp
(
token
)
{
const
path
=
`
${
BASE_URL
}
/pipeline/get_range_ts`
const
body
=
{
...
...
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