Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix real-time added patterns persistence with DIFFERENTIAL updates #5726
Fix real-time added patterns persistence with DIFFERENTIAL updates #5726
Changes from 1 commit
e432a38
d3f467d
9630a4a
0177fb4
f518363
dfe08af
7cdbe3d
459348d
b98c3c8
c653f56
0aa8374
4d73ce7
e7ae470
fe8d52b
b9526c3
bdf7161
1cb32d9
51d7550
441bd5c
83da1d8
bc06c14
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels to me like this Javadoc and the name of this method might be misrepresenting its purpose. Please confirm if my understanding is correct. The method doesn't exactly remove a trip update, it removes some objects created only if a trip update with very particular characteristics has been applied. These are specifically a realtime-created TripPattern and the single trip that is expected to be present on that same TripPattern. And crucially, it only performs this removal if the supplied tripId has previously caused a new TripPattern to be created (conditional on the
pattern != null
block), which only happens when the stop sequence is changed by the update.The Javadoc (and maybe the name) gives the impression that this method takes an action if any update has ever been applied to the given trip and service date combination, but the actual field of application is much narrower.
Aside: the
@param serviceDate service date
annotation seems trivial/redundant and should probably be removed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree with. I copied over the javadoc when I moved this method from the
SiriTimetableSnapshotSource
to here. I can update the javadoc to better match what the method does.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The private method removeLastAddedTripPattern is only one line long, is located in the same file, and is only called in this one place. Should it just be inlined here?
The private method removeRealtimeUpdatedTripTimes called on the next line is much longer, but similarly it's called only here in a method that's only a few lines long. Should it also be inlined here?
The tree of methods removePreviousRealtimeUpdate calling removeLastAddedTripPattern and removeRealtimeUpdatedTripTimes looks more complicated than it really is, and the whole tree is only called in 2 places. It's also a little confusing due to slight differences in the method names, raising doubts whether maybe "previous" means something different than "last added" and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like a good idea. The mixture of different language around these "added trip patterns" is indeed slightly confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on better names, -1 on inlining
removeRealtimeUpdatedTripTimes
. One line methods have their place, even if only used once. If named properly they may explain/give an hint on the intention. A longer explination/description can go in the JavaDoc, which help keeping the caller method cleaner - shorter and at the same abstraction level.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can discuss this in the dev meeting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this necessarily remove the trip pattern entirely from the cache? It seems to only remove the mapping from one particular TripIdAndServiceDate to the TripPattern, but the TripPattern could continue to be present for other keys.
The fact that this map is being referred to as a "cache" implies that the values are being reused, potentially for more than one tripId. I'm trying to establish whether there's an assumption throughout this part of the code that when a trip is changed such that it creates a new TripPattern, it's the only trip on that pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are correct. I can improve the javadoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the things I want to change with refactoring of the transit model. The goal should be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too happy about passing down a boolean to method which leads to an immediate return and I would like to handle it earlier.
In an ideal world Java would have a syntax like this:
but it doesn't.
How about catching that case before the switch? So something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I agree with you. However, the handleCanceledTrip is where you expect the handling of any valid case of a CANCELED/DELETED scheduled relationship to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you moving these call up because they happen for every scenario or is there another reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were two reasons, one of them was that I saw this was used in every scenario and the other was that I was unsure what would happen if I run the new code before this. However, I think moving this creates a minor regression as now the previously added trip is always deleted. However, I think previously if you sent a CANCELLED message on the trip, it was just cancelled, not removed. Do we want to keep that behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So an ADDED trip was then CANCELLED again? If so, I'm quite relaxed about that but I would like to see tests documenting all these weird edge cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's just cancelling ADDDED trips, I think it doesn't matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@t2gran do you know how cancellation of an added trip works in SIRI? Do we cancel or remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should cancel it. I have asked @lassetyr about this now, and in the future we want to be able to "cancel" any previously added update - DELETE in GTFS?
Summary of my thought about this - related to todays dev meeting discussion:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name seems confusing - was this converted from a boolean at some point? Maybe it should just be called
cancelationType
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can rename this.