Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libraries
KPublicTransport
Commits
9e1fc016
Commit
9e1fc016
authored
Apr 18, 2021
by
Volker Krause
Browse files
Use the new coverage data for determining journey query backends as well
parent
31c42dc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/manager.cpp
View file @
9e1fc016
...
...
@@ -331,13 +331,6 @@ static Location::Types locationTypesForJourneyRequest(const JourneyRequest &req)
bool
ManagerPrivate
::
queryJourney
(
const
AbstractBackend
*
backend
,
const
JourneyRequest
&
req
,
JourneyReply
*
reply
)
{
if
(
shouldSkipBackend
(
backend
,
req
))
{
return
false
;
}
if
(
backend
->
isLocationExcluded
(
req
.
from
())
&&
backend
->
isLocationExcluded
(
req
.
to
()))
{
qCDebug
(
Log
)
<<
"Skipping backend based on location filter:"
<<
backend
->
backendId
();
return
false
;
}
reply
->
addAttribution
(
backend
->
attribution
());
auto
cache
=
Cache
::
lookupJourney
(
backend
->
backendId
(),
req
.
cacheKey
());
...
...
@@ -528,9 +521,28 @@ JourneyReply* Manager::queryJourney(const JourneyRequest &req) const
// first time/direct query
if
(
req
.
contexts
().
empty
())
{
for
(
const
auto
&
backend
:
d
->
m_backends
)
{
if
(
d
->
queryJourney
(
BackendPrivate
::
impl
(
backend
),
req
,
reply
))
{
++
pendingOps
;
QSet
<
QString
>
triedBackends
;
bool
foundNonGlobalCoverage
=
false
;
for
(
const
auto
coverageType
:
{
CoverageArea
::
Realtime
,
CoverageArea
::
Regular
,
CoverageArea
::
Any
})
{
for
(
const
auto
&
b
:
d
->
m_backends
)
{
const
auto
backend
=
BackendPrivate
::
impl
(
b
);
if
(
triedBackends
.
contains
(
backend
->
backendId
())
||
d
->
shouldSkipBackend
(
backend
,
req
))
{
continue
;
}
const
auto
coverage
=
b
.
coverageArea
(
coverageType
);
if
(
coverage
.
isEmpty
()
||
(
!
coverage
.
coversLocation
(
req
.
from
())
&&
!
coverage
.
coversLocation
(
req
.
to
())))
{
continue
;
}
triedBackends
.
insert
(
backend
->
backendId
());
foundNonGlobalCoverage
|=
!
coverage
.
isGlobal
();
if
(
d
->
queryJourney
(
backend
,
req
,
reply
))
{
++
pendingOps
;
}
}
if
(
pendingOps
&&
foundNonGlobalCoverage
)
{
break
;
}
}
...
...
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