Skip to content

Commit

Permalink
Merge pull request #4244 from hove-io/optim_disable_feedpublisher
Browse files Browse the repository at this point in the history
Optim disable_feedpublisher
  • Loading branch information
azime authored Mar 19, 2024
2 parents d4a8f39 + 3289050 commit 4ef1e12
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/jormungandr/jormungandr/georef.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def get_car_co2_emission_on_crow_fly(self, origin, destination, request_id):
req.car_co2_emission.origin.access_duration = 0
req.car_co2_emission.destination.place = destination
req.car_co2_emission.destination.access_duration = 0
req.disable_feedpublisher = True

response = self.instance.send_and_receive(req, request_id=request_id)
if response.error and response.error.id == response_pb2.Error.error_id.Value('no_solution'):
Expand All @@ -81,6 +82,7 @@ def get_physical_mode(self, uri, request_id):
req.ptref.start_page = 0
req.ptref.count = 1
req.ptref.depth = 1
req.disable_feedpublisher = True
res = self.instance.send_and_receive(req, request_id=request_id)
if res.physical_modes:
return res.physical_modes[0]
Expand Down Expand Up @@ -165,6 +167,7 @@ def get_stop_points_uris_for_stop_area(self, stop_area_uri, request_id):
req.ptref.count = 100
req.ptref.start_page = 0
req.ptref.depth = 0
req.disable_feedpublisher = True
req.ptref.filter = 'stop_area.uri = {uri}'.format(uri=stop_area_uri)
return self.instance.send_and_receive(req, request_id=request_id)

Expand All @@ -190,6 +193,7 @@ def get_stop_points_from_uri(self, uri, request_id, depth=0):
req.ptref.count = 100
req.ptref.start_page = 0
req.ptref.depth = depth
req.disable_feedpublisher = True
req.ptref.filter = 'stop_point.uri = {uri}'.format(uri=uri)
result = self.instance.send_and_receive(req, request_id=request_id)
return result.stop_points
Expand All @@ -199,4 +203,5 @@ def get_odt_stop_points(self, coord, request_id):
req.requested_api = type_pb2.odt_stop_points
req.coord.lon = coord.lon
req.coord.lat = coord.lat
req.disable_feedpublisher = True
return self.instance.send_and_receive(req, request_id=request_id).stop_points
2 changes: 2 additions & 0 deletions source/jormungandr/jormungandr/pt_planners/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def get_odt_stop_points(pt_planner, coord, request_id):
req.requested_api = type_pb2.odt_stop_points
req.coord.lon = coord.lon
req.coord.lat = coord.lat
req.disable_feedpublisher = True
return pt_planner.send_and_receive(req, request_id=request_id).stop_points


Expand All @@ -174,6 +175,7 @@ def get_stop_points_from_uri(pt_planner, uri, request_id, depth=0):
req.ptref.count = 100
req.ptref.start_page = 0
req.ptref.depth = depth
req.disable_feedpublisher = True
req.ptref.filter = 'stop_point.uri = {uri}'.format(uri=uri)
result = pt_planner.send_and_receive(req, request_id=request_id)
return result.stop_points
8 changes: 8 additions & 0 deletions source/jormungandr/tests/routing_tests_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ def test_first_and_last_section_multi_modes(self):
# This will call jormun so we check our counter before
self.is_valid_journey_response(response, query)

feed_publishers = get_not_null(response, "feed_publishers")
assert len(feed_publishers) == 1
feed_publisher = feed_publishers[0]
assert feed_publisher["id"] == "builder"
assert feed_publisher["name"] == 'routing api data'
assert feed_publisher["license"] == "ODBL"
assert feed_publisher["url"] == "www.hove.com"

def test_first_and_last_section_multi_modes_no_debug(self):
"""Test to verify optimization of direct path calls"""
# Initialize counter value in the object MockKraken
Expand Down
12 changes: 12 additions & 0 deletions source/kraken/tests/worker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ BOOST_FIXTURE_TEST_CASE(no_wheelchair_on_vj_tests, fixture) {
pbnavitia::Journey journey = resp.journeys(0);

BOOST_CHECK_EQUAL(journey.arrival_date_time(), navitia::test::to_posix_timestamp("20150314T090000"));

BOOST_CHECK_EQUAL(resp.feed_publishers_size(), 1);
pbnavitia::FeedPublisher fp = resp.feed_publishers(0);
BOOST_CHECK_EQUAL(fp.license(), "ODBL");
BOOST_CHECK_EQUAL(fp.name(), "hove");
BOOST_CHECK_EQUAL(fp.url(), "www.hove.com");
}

BOOST_FIXTURE_TEST_CASE(wheelchair_on_vj_tests, fixture) {
Expand All @@ -201,6 +207,12 @@ BOOST_FIXTURE_TEST_CASE(wheelchair_on_vj_tests, fixture) {
pbnavitia::Journey journey = resp.journeys(0);

BOOST_CHECK_EQUAL(journey.arrival_date_time(), navitia::test::to_posix_timestamp("20150314T100000"));

BOOST_CHECK_EQUAL(resp.feed_publishers_size(), 1);
pbnavitia::FeedPublisher fp = resp.feed_publishers(0);
BOOST_CHECK_EQUAL(fp.license(), "ODBL");
BOOST_CHECK_EQUAL(fp.name(), "hove");
BOOST_CHECK_EQUAL(fp.url(), "www.hove.com");
}

BOOST_FIXTURE_TEST_CASE(wheelchair_on_stop_tests, fixture) {
Expand Down
3 changes: 3 additions & 0 deletions source/type/pb_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ void PbCreator::Filler::add_contributor(const T* nav) {
if (pb_creator.disable_feedpublisher) {
return;
}
if (pb_creator.data->pt_data->contributors.size() == pb_creator.contributors.size()) {
return;
}
const auto& contributors = ptref_indexes<nt::Contributor>(nav);
for (const nt::Contributor* c : contributors) {
if (!c->license.empty()) {
Expand Down

0 comments on commit 4ef1e12

Please sign in to comment.