hove-io / navitia

The open source software to build cool stuff with locomotion
https://www.navitia.io/
GNU Affero General Public License v3.0
434 stars 126 forks source link

Only NO_SERVICE disruptions on line_sections are linked on /lines requests #2225

Closed eturck closed 6 years ago

eturck commented 7 years ago

Hello!

We are using a lot of disruptions on line sections. For example it is used for :

The problem we have is, when we are requesting /v1/coverage/tisseo/lines, some disruptions are not shown. And that's all the disruptions which are not with a "NO_SERVICE" effect.

We discuss this a bit on the phone with @kinnou02 and @antoine-de a few months ago, but we never made the issue. The problem appeared when you changed a bunch of stuff to be able to properly display disruptions on line_section, which is a good thing, but introduced this :).

I kind of know why it is happening, but don't really know how to properly fix it. It's in pb_converter : https://github.com/CanalTP/navitia/blob/dev/source/type/pb_converter.cpp#L620 And there is a pretty obvious comment about it. Here is the relevant part :

if (dump_message_options ==  DumpMessageOptions{DumpMessage::Yes, DumpLineSectionMessage::Yes} ) {
    /*
     * Here we dump the impacts which impact LineSection.
     * We could have link the LineSection impact with the line, but that would change the code and
     * the behavior too much.
     * */
    std::set<boost::shared_ptr<nt::disruption::Impact>> added_impact;
    auto fill_line_section_message = [&](const nt::VehicleJourney& vj) {
        for(const auto& impact: vj.meta_vj->impacted_by) {
            auto impact_ptr = impact.lock();
            if (! impact_ptr)
                continue;
            for (const auto& entity: impact_ptr->informed_entities()) {
                if (boost::get<nt::disruption::LineSection>(&entity) &&
                        added_impact.insert(impact_ptr).second ) {
                    fill_messages(vj.meta_vj, line);
                    return true;
                }
            }
        }
        return true;
    };
    for(const auto* route: l->route_list) {
        route->for_each_vehicle_journey(fill_line_section_message);
    }
}

Problem is, we loop on the vehicle_journeys to see if they are impacted, and we add the message to the line if that's the case. But in apply_disruption we have, at the start of the method applying a line section disruption :

if (impact->severity->effect != nt::disruption::Effect::NO_SERVICE) {
    LOG4CPLUS_DEBUG(log, "Unhandled action on " << uri);
    this->log_end_action(uri);
    return
}

The OTHER_EFFECT disruptions will not impact any vehicle_journey, therefore, we don't have it in /lines. Without too much thinking I can see two ways to fix this, but I really don't know the side effect they would cause :

Let me know what you think!

TeXitoi commented 6 years ago

I suspect the good answer would be impacting the meta_vj without creating a new vj. I don't think it will break anything.

We have the same issue here as https://jira.canaltp.fr/browse/NAVITIAII-2302

eturck commented 6 years ago

I don't have access to your jira so I don't really know what the exact issue is for you. Since your suggestion seemed pretty easy to implement I took a quick look at the code but it made me have a few more questions :

TeXitoi commented 6 years ago

Our problem is that with a LineSection of SIGNIFICANT_DELAY, the disruption doesn't output in lines, line_reports, departures, stop_schedules and journeys.

TeXitoi commented 6 years ago

Currently a SIGNIFICANT_DELAYS impact create a new vj with the stop_point impacted removed, a bug maybe?

Yes, that's obviously a bug.

TeXitoi commented 6 years ago

Currently a SIGNIFICANT_DELAYS impact create a new vj with the stop_point impacted removed, a bug maybe?

Mmm, I suspect that we should look at impacts, not impacted_by, but I may be wrong. @xlqian what do you think? Related PR: https://github.com/CanalTP/navitia/pull/2087

eturck commented 6 years ago

Any update on this?

TeXitoi commented 6 years ago

No update for the moment. We'll ping here if we begin the dev.

eturck commented 6 years ago

I was asking because we are open to fix this bug ourselves if you don't necessarily have the time right now. But I am not sure if the correct fix is just to look into impacts and not impacted_by or if there is more to it.

TeXitoi commented 6 years ago

I'm looking at it right now.