Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bahn-proxy
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
Service Desk
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
Janne Mareike Koschinski
bahn-proxy
Commits
a17b8664
Commit
a17b8664
authored
6 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Merge realtime and plan data
parent
e646a549
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.go
+9
-23
9 additions, 23 deletions
main.go
merge.go
+41
-0
41 additions, 0 deletions
merge.go
with
50 additions
and
23 deletions
main.go
+
9
−
23
View file @
a17b8664
...
...
@@ -133,33 +133,19 @@ func main() {
log
.
Fatal
(
err
)
return
}
if
err
=
returnJson
(
w
,
timetabl
e
);
err
!=
nil
{
var
realtime
bahn
.
Timetable
if
realtime
,
err
=
apiClient
.
RealtimeAll
(
evaId
,
dat
e
);
err
!=
nil
{
log
.
Fatal
(
err
)
return
}
})
http
.
HandleFunc
(
"/realtime/"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
err
error
_
,
rawEvaId
:=
path
.
Split
(
r
.
URL
.
Path
)
rawEvaId
=
strings
.
TrimSpace
(
rawEvaId
)
var
evaId
int64
if
evaId
,
err
=
strconv
.
ParseInt
(
rawEvaId
,
10
,
64
);
err
!=
nil
{
log
.
Fatal
(
err
)
return
}
var
date
time
.
Time
if
date
,
err
=
time
.
Parse
(
time
.
RFC3339
,
strings
.
TrimSpace
(
r
.
FormValue
(
"time"
)));
err
!=
nil
{
date
=
time
.
Now
()
realtimeData
:=
make
(
map
[
string
]
*
bahn
.
TimetableStop
)
for
i
:=
range
realtime
.
Stops
{
stop
:=
realtime
.
Stops
[
i
]
realtimeData
[
stop
.
StopId
]
=
&
stop
}
var
timetable
bahn
.
Timetable
if
timetable
,
err
=
apiClient
.
RealtimeAll
(
evaId
,
date
);
err
!=
nil
{
log
.
Fatal
(
err
)
return
for
i
:=
range
timetable
.
Stops
{
stop
:=
&
timetable
.
Stops
[
i
]
MergeTimetableStop
(
stop
,
realtimeData
[
stop
.
StopId
])
}
if
err
=
returnJson
(
w
,
timetable
);
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
merge.go
0 → 100644
+
41
−
0
View file @
a17b8664
package
main
import
(
"git.kuschku.de/justjanne/bahn-api"
)
func
MergeTimetableStop
(
data
*
bahn
.
TimetableStop
,
realtime
*
bahn
.
TimetableStop
)
{
if
data
==
nil
||
realtime
==
nil
{
return
}
data
.
Messages
=
realtime
.
Messages
MergeTripLabel
(
&
data
.
TripLabel
,
&
realtime
.
TripLabel
)
MergeTimetableStop
(
data
.
Ref
,
realtime
.
Ref
)
MergeEvent
(
data
.
Arrival
,
realtime
.
Arrival
)
MergeEvent
(
data
.
Departure
,
realtime
.
Departure
)
data
.
HistoricDelays
=
realtime
.
HistoricDelays
data
.
HistoricPlatformChanges
=
realtime
.
HistoricPlatformChanges
data
.
Connections
=
realtime
.
Connections
}
func
MergeTripLabel
(
data
*
bahn
.
TripLabel
,
realtime
*
bahn
.
TripLabel
)
{
if
data
==
nil
||
realtime
==
nil
{
return
}
data
.
Messages
=
realtime
.
Messages
}
func
MergeEvent
(
data
*
bahn
.
Event
,
realtime
*
bahn
.
Event
)
{
if
data
==
nil
||
realtime
==
nil
{
return
}
data
.
Messages
=
realtime
.
Messages
data
.
ChangedPlatform
=
realtime
.
ChangedPlatform
data
.
ChangedTime
=
realtime
.
ChangedTime
data
.
ChangedPath
=
realtime
.
ChangedPath
data
.
ChangedDestination
=
realtime
.
ChangedDestination
data
.
ChangedStatus
=
realtime
.
ChangedStatus
}
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