Skip to content

Conversation

@mmathieum
Copy link
Member

@mmathieum mmathieum commented Oct 15, 2025

A simple most reliable way to match direction between trips is too look for stops in the same direction (stop1->stop2->...->stopN) in both trips.

@mmathieum mmathieum self-assigned this Oct 15, 2025
@mmathieum

This comment was marked as outdated.

@mmathieum

This comment was marked as outdated.

@mmathieum mmathieum marked this pull request as ready for review October 15, 2025 23:45
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new mechanism to identify if two lists of stops share items in the same order, which is then used in the direction splitting logic. The core logic in countItemsGoingIntoSameOrder has some critical performance issues due to inefficient list manipulation, and could be improved for readability. The new tests are good but contain some debug statements and code duplication that should be addressed. I've provided suggestions to refactor the new function for performance and to clean up the tests.

@mmathieum

This comment was marked as outdated.

@mmathieum mmathieum changed the title Direction splitter > stops in same directions Direction splitter > stops in same direction Oct 16, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new collection extension functions, hasItemsGoingIntoSameOrder and countItemsGoingIntoSameOrder, to identify sequences of items that appear in the same order across two collections. This new logic is then integrated into MDirectionSplitter to improve direction detection. The implementation is functionally sound and the accompanying tests provide good coverage. My review includes suggestions to enhance the readability and structure of the new functions, and to clean up the test code.

@mmathieum
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new way to match trip directions by looking for common sequences of stops. The core logic is in the new countItemsGoingIntoSameOrder function.

My review found a critical issue in this new function where its result can be non-deterministic due to iterating over an unordered Set. I've provided a corrected implementation. I also have a suggestion to reduce code duplication in the new tests.

Overall, the approach is a good addition to the direction splitting logic, but the implementation needs to be corrected to ensure reliable behavior.

@mmathieum
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new mechanism for matching trip directions by finding common sequences of stops. The implementation adds new extension functions to CollectionsExt.kt along with corresponding tests. The new logic is then integrated into MDirectionSplitter.kt. The changes are logical and well-tested. I've provided a few suggestions to improve code encapsulation, performance, and test maintainability.

@mmathieum mmathieum merged commit 1de4a81 into master Oct 16, 2025
1 check passed
@mmathieum mmathieum deleted the mm/dir_splitter_stops_in_same_dir branch October 16, 2025 01:19
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.

2 participants