Skip to content
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

Adding Intersection API Pagination #165

Merged

Conversation

jacob6838
Copy link
Collaborator

@jacob6838 jacob6838 commented Feb 18, 2025

PR Details

Description

This is a small sample PR, showing what an Intersection API custom pagination solution could look like. This implementation uses aggregation queries to complete the query and count in one operation. One concern was that these types of aggregation queries would not utilize indexes - I have confirmed that the compound index "intersectionID_-1_notificationGeneratedAt_-1" is utilized for aggregated queries to the CmConnectionOfTravel collection.
Here is a sample of the response to the /notifications/connection_of_travel?intersection_id=12109&size=1 endpoint (2 records exist):

{
    "content": [
        {
            "_id": {
                "timestamp": 1724170732,
                "date": 1724170732000
            },
            "notificationGeneratedAt": 1724170732774,
            "assessment": {
                "assessmentGeneratedAt": 1724170732774,
                "assessmentType": "ConnectionOfTravel",
                "roadRegulatorID": -1,
                "intersectionID": 12109,
                "connectionOfTravelAssessmentGroups": [
                    {
                        "egressLaneID": 5,
                        "ingressLaneID": 3,
                        "connectionID": -1,
                        "eventCount": 11
                    }
                ],
                "source": "{\"rsuId\":\"10.11.81.12\",\"intersectionId\":12109,\"region\":0}",
                "timestamp": 1724170732774
            },
            "egressLane": 5,
            "ingressLane": 3,
            "notificationText": "Connection of Travel Notification, Unknown Lane connection between ingress lane: 3 and egress lane: 5.",
            "notificationHeading": "Connection of Travel Notification",
            "roadRegulatorID": -1,
            "intersectionID": 12109,
            "notificationType": "ConnectionOfTravelNotification",
            "key": "ConnectionOfTravelNotification_12109_-1_0_0"
        }
    ],
    "pageable": {
        "pageNumber": 0,
        "pageSize": 1,
        "sort": {
            "sorted": false,
            "empty": true,
            "unsorted": true
        },
        "offset": 0,
        "paged": true,
        "unpaged": false
    },
    "last": false,
    "totalPages": 2,
    "totalElements": 2,
    "first": true,
    "size": 1,
    "number": 0,
    "sort": {
        "sorted": false,
        "empty": true,
        "unsorted": true
    },
    "numberOfElements": 1,
    "empty": false
}

How Has This Been Tested?

Types of changes

  • Defect fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that cause existing functionality to change)

Checklist:

  • My changes require new environment variables:
    • I have updated the docker-compose, K8s YAML, and all dependent deployment configuration files.
  • My changes require updates to the documentation:
    • I have updated the documentation accordingly.
  • My changes require updates and/or additions to the unit tests:
    • I have modified/added tests to cover my changes.
  • All existing tests pass.

@jacob6838 jacob6838 requested a review from John-Wiens February 18, 2025 19:12
@jacob6838 jacob6838 requested a review from mcook42 February 18, 2025 21:45
Copy link

@mcook42 mcook42 left a comment

Choose a reason for hiding this comment

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

This is looking slick! There's one blocking chore and a few suggestions. Once you decide how you want to address the chore and suggestions, I'll be pretty quick to approve this. Nice work!

@jacob6838 jacob6838 requested a review from mcook42 February 26, 2025 15:35
Copy link

@mcook42 mcook42 left a comment

Choose a reason for hiding this comment

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

great work!

jacob6838 and others added 4 commits February 26, 2025 15:19
…/api/accessors/notifications/ConnectionOfTravelNotification/ConnectionOfTravelNotificationRepositoryImpl.java

Co-authored-by: John-Wiens <jwiens3141@gmail.com>
…/api/accessors/notifications/ConnectionOfTravelNotification/ConnectionOfTravelNotificationRepositoryImpl.java

Co-authored-by: John-Wiens <jwiens3141@gmail.com>
@jacob6838 jacob6838 requested a review from John-Wiens February 26, 2025 22:30
@jacob6838 jacob6838 marked this pull request as ready for review February 26, 2025 22:32
@jacob6838 jacob6838 merged commit b4c09e1 into intersection-api-mongo-query-limits Feb 28, 2025
8 checks passed
@jacob6838 jacob6838 deleted the intersection-api-pagination branch February 28, 2025 15:47
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.

3 participants