Skip to content

Update GtfsRealtime and include severity, effect and cause from GTFS RT#3747

Merged
optionsome merged 20 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:alert-updates
Nov 30, 2021
Merged

Update GtfsRealtime and include severity, effect and cause from GTFS RT#3747
optionsome merged 20 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:alert-updates

Conversation

@optionsome
Copy link
Copy Markdown
Member

@optionsome optionsome commented Nov 15, 2021

Summary

  • Updates the generated GtfsRealtime file (this had to be done so severity level information from GTFS RT datas could be included)
  • Includes severity, cause and effect from GTFS RT updater to transit alerts
    • Refactored severity from a string to enum and updated its use in SIRI/transmodel
  • Implements alerts for the LegacyGraphQL API
  • Fixes an issue where agency selector was attempted to be added even though there was none
  • Changes missing start in active_period to be returned as null from effective start instead of 0

Issue

closes #3653

Unit tests

Updated tests related to SIRI and added tests for GTFS RT alerts.

Code style

Used the intellij formatting rules

Documentation

Not needed?

Changelog

From title and updated legacyGraphQL changelog

@optionsome optionsome requested a review from a team as a code owner November 15, 2021 16:20
Copy link
Copy Markdown
Member Author

@optionsome optionsome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need clarification for the commented things before I'll finish this pr.

// TODO
// This is deprecated
@Override
public DataFetcher<Iterable<TripPattern>> patterns() {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should be fixed or not

return AlertSeverity.WARNING;
}
switch (severity) {
case PTI_26_255:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to map these values into what seems to be their human readable versions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general principle, I don't think OTP should change any of the data provided in any service.
However, all the PTI_-values have been removed in the upcoming version of SIRI, so I am not sure if these values are actually needed anymore.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the transmodel enum for the severity doesn't contain those so I'm not sure what would happen now if someone tried to use a SIRI updater that used the PTI_-values together with the transmodel API. We could alternatively just map these PTI_-values to the values known by the transmodel API in that side instead of when loading in the severities to the internal data model. But as you pointed out about the upcoming change, I'm not sure if that is worth the effort here.

/**
* An enum containing cause options for an alert.
*/
public enum AlertCause {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is creating these duplicate enums for the internal model wanted?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided that it's better to use duplicate enums for the internal data models instead of using enum directly from the GTFS RT library.

@@ -67,7 +67,7 @@ type Alert implements Node {
stop: Stop
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These stop, route, agency and trip fields need to be replaced with stops etc because alerts can have multiple entities but I'm not sure what is the ideal way. Should the stops etc field be at the root level of the alert of under some entities field in some way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this in today's meeting. @hannesj suggested that we should implement the entities similarly as the places in the nearest query so you need to use fragments to handle the different entity types.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in 1ee1514

return environment -> null;
return environment -> {
var text = getSource(environment).alertDescriptionText;
return text instanceof TranslatedString
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated code. Can you use a reusable method?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I'll do that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed that now in 973c9f3

@t2gran t2gran added this to the 2.1 milestone Nov 16, 2021
@t2gran t2gran requested a review from lassetyr November 16, 2021 11:26
@optionsome optionsome marked this pull request as draft November 16, 2021 11:48
@optionsome optionsome changed the title WIP: Update GtfsRealtime and include severity, effect and cause from GTFS RT Update GtfsRealtime and include severity, effect and cause from GTFS RT Nov 16, 2021
@optionsome optionsome marked this pull request as ready for review November 18, 2021 12:45
@optionsome
Copy link
Copy Markdown
Member Author

This is ready for review now. I'll also do some final checks with different kinds of alerts data in the meanwhile. One difference I noticed at least when compared against the hsldevcom fork of OTP1 is that the default values for the translated fields where in Finnish in OTP1 but in English in OTP2. I'm not sure what causes the difference but maybe it should be possible to add an option to configure the default language if that is not already possible somehow.

lassetyr
lassetyr previously approved these changes Nov 18, 2021
Copy link
Copy Markdown
Contributor

@lassetyr lassetyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@optionsome
Copy link
Copy Markdown
Member Author

optionsome commented Nov 23, 2021

Found some issues while testing and fixed those. e7964d8 was an existing issue when only route_type entity was defined, it tried to add agency selector with empty string which lead to an error. 60706bc makes the start time behave like the end time so if they are not set, null is returned.

I plan to add support for the route_type selector (and probably also trip direction) in a separate pull request and also allow alerts with no known selectors to be included (now they are not added if they have no selectors known by OTP).

t2gran
t2gran previously approved these changes Nov 23, 2021
Copy link
Copy Markdown
Member

@t2gran t2gran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lassetyr has reviewed and approved this from Entur, and I quickly looked trough code - so I will approve this on behalf of Entur.

@optionsome optionsome dismissed stale reviews from leonardehrenfried and t2gran via 6b72182 November 30, 2021 12:34
@optionsome optionsome merged commit 919f892 into opentripplanner:dev-2.x Nov 30, 2021
@optionsome optionsome deleted the alert-updates branch November 30, 2021 14:05
t2gran pushed a commit that referenced this pull request Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include Cause, Effect and Severity Level from GTFS RT alerts

4 participants