Convert transferSlack configuration to duration - #5897
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5897 +/- ##
=============================================
- Coverage 69.45% 69.45% -0.01%
+ Complexity 17070 17068 -2
=============================================
Files 1937 1937
Lines 73692 73699 +7
Branches 7540 7542 +2
=============================================
Hits 51184 51184
- Misses 19880 19884 +4
- Partials 2628 2631 +3 ☔ View full report in Codecov by Sentry. |
3e521cd to
e5ea70d
Compare
| This also influences the time it takes to transfer. | ||
|
|
||
| Since some modes, like airplanes and subways, need more time than others, this is also configurable | ||
| per mode with `boardSlackForMode`. |
There was a problem hiding this comment.
alightSlackForMode*, for some reason there isn't suggestion option when adding review comment 🤔 .
There was a problem hiding this comment.
Ah I think it was because I was reviewing commit instead of overall changes.
Co-authored-by: Thomas Gran <t2gran@gmail.com> Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
…st/TransferConfig.java Co-authored-by: Thomas Gran <t2gran@gmail.com>
|
|
||
| This time slack is added to arrival time of the vehicle before any transfer or onward travel. | ||
|
|
||
| The sole reason for this is to avoid missed connections when there are minor schedule variations. This |
There was a problem hiding this comment.
I wasn't properly concentrating today during the developer meeting discussion, but isn't this the description of transferSlack, not alightSlack? I thought alightSlack was mostly meant just for random procedures you have to do after you alight from a vehicle like with airplanes. Although, this is the generic one and I'm not even completely sure what this is for. Maybe if you are traveling on wheelchair this could be useful you if you need assistance or if the vehicles are crowded and getting off a vehicle takes time.
Referring to connection feels a bit weird. This feels more like a safety margin that you get to the destination in time.
There was a problem hiding this comment.
It's possible that I misinterpreted the purpose of the different parameters. I tried to verify with everyone that any strong statements were accurate. I'm happy to rewrite it if it's incorrect.
There was a problem hiding this comment.
To me the description is good. The following sentence could be better:
The sole reason for this is to avoid missed connections when there are minor schedule variations.
It should emphasise "minor schedule variations". Note! It is probably a better simulation of real life to have 20s boardSlack and 10s alightSlack, than 30s/0s. But, due to technical difficulties in presenting this to the end user, most deployments uses just boardSlack. I do not recommend using this for user-specific needs like wheelchair.
We can refrase to, if less confusing:
The main reason is to account for minor schedule variations.
|
|
||
| This is the same as the `transferSlack`, except that this also applies to to the first | ||
| transit leg in the trip. This is the default value used, if not overridden by the `boardSlackList`. | ||
| The sole reason for this is to avoid missed connections when there are minor schedule variations. This |
There was a problem hiding this comment.
Again, connection to me refers more to a transfer than potentially the only boarding but I'm not a native speaker.
There was a problem hiding this comment.
I agree, however please see above.
abyrd
left a comment
There was a problem hiding this comment.
Here are some suggested revisions reflecting @joelhaasnoot's comments and @leonardehrenfried's clarifications.
| @ParameterizedTest | ||
| @ValueSource(strings = { "transferSlack", "minimumTransferTime" }) | ||
| public void testTransferSlack(String name) { |
There was a problem hiding this comment.
This need a comment or a different name. I assume it is testing backward compatibility of the old name?
If you try to do two things at once, I would instead make two tests instead. Then the intention can be communicated in the test name.
There was a problem hiding this comment.
It is indeed for backwards-compatibility: I clarifi€d in 468bb83
Co-authored-by: Andrew Byrd <abyrd@conveyal.com>
f8b00a2 to
468bb83
Compare
| @ValueSource(strings = { "transferSlack", "minimumTransferTime" }) | ||
| public void testTransferSlack(String name) { | ||
| public void testBackwardsCompatibleTransferSlack(String name) { | ||
| Map<String, Object> arguments = Map.of(name, 101); | ||
| var req = TripRequestMapper.createRequest(executionContext(arguments)); | ||
| assertEquals(Duration.ofSeconds(101), req.preferences().transfer().slack()); |
There was a problem hiding this comment.
I would have written this like the suggestion below witch I think is fare more readable. The reason why this test is confusing is that the variable arguments is not used to provide different test-cases, but alias/old name of the property. Then, if you need to extend the test-cases here it become very ugly. It also test two different things - we are not strict about that, but to some it might be confusing. You could also split it in 3 methods => no need for any comment, just clear names.
@Test
public void testTransferSlack() {
var d101s = Duration.ofSeconds(101);
var req = TripRequestMapper.createRequest(executionContext(Map.of("transferSlack", 101)));
assertEquals(d101s, req.preferences().transfer().slack());
assertThrows(..., () ->
TripRequestMapper.createRequest(executionContext(Map.of("transferSlack", <invalid value>)));
);
// Test the deprecated 'minimumTransferTime' for backwards compatibility
req = TripRequestMapper.createRequest(executionContext(Map.of("transferSlack", 101)));
assertEquals(d101s, req.preferences().transfer().slack());
}
Summary
Convert the
transferSlackconfiguration option to a duration. In order to preserve backwards-compatibility with Entur's stack, this is backwards compatible.Unit tests
Added for config value and API mappers.
Documentation
Updated.