Skip to content

Extend routing API to fetch and combine route-specific preferences with global preferences#58

Merged
zlendo1 merged 2 commits into
developmentfrom
copilot/update-routing-api-logic
Nov 13, 2025
Merged

Extend routing API to fetch and combine route-specific preferences with global preferences#58
zlendo1 merged 2 commits into
developmentfrom
copilot/update-routing-api-logic

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 13, 2025

The /search endpoint previously only fetched global preferences. It now fetches and combines both global and route-specific preferences matching the exact origin/destination coordinates before sending to the AI agents service.

Service layer

  • Added get_preferences_by_coordinates() to route_preference_service that filters by exact coordinate match with user isolation

API endpoint

  • Updated /api/v1/routes/search to fetch three preference types in order:
    1. Request preferences (inline from request body)
    2. Global preferences (user's stored defaults)
    3. Route-specific preferences (matching exact coordinates)
  • Combined list sent to AI agents service
  • Graceful degradation on individual fetch failures

Example usage:

# User has global preference: "prefer eco-friendly routes"
# User has route-specific preference for (60.17, 24.94) → (60.21, 24.66): "avoid construction"
# Request includes: "prefer faster routes"

# All three are now combined and sent to AI agents:
preferences = [
    {"prompt": "prefer faster routes"},      # from request
    {"prompt": "prefer eco-friendly routes"}, # global
    {"prompt": "avoid construction"}          # route-specific
]

Testing

  • 10 new tests covering coordinate matching, preference combinations, and failure scenarios
Original prompt

This section details on the original issue you should resolve

<issue_title>Update the logic of the routing API fetching preferences</issue_title>
<issue_description>New preference fetching /search logic should:

  • Get all the global preferences
  • Get all the route-specific preferences with matching coordinates

Send combined preference list to ai_agents_service for processing as before.</issue_description>

<agent_instructions>Cover tests for this.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Add get_preferences_by_coordinates method to route_preference_service
- Update /search endpoint to fetch both global and route-specific preferences
- Combine all preference types (request, global, route-specific) for AI processing
- Add comprehensive tests for new functionality
- Ensure graceful degradation if preference services fail

Co-authored-by: zlendo1 <115471708+zlendo1@users.noreply.github.com>
Copilot AI changed the title [WIP] Update logic of routing API for fetching preferences Extend routing API to fetch and combine route-specific preferences with global preferences Nov 13, 2025
Copilot AI requested a review from zlendo1 November 13, 2025 15:16
Copy link
Copy Markdown
Contributor

@zlendo1 zlendo1 left a comment

Choose a reason for hiding this comment

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

Lgtm

@zlendo1 zlendo1 marked this pull request as ready for review November 13, 2025 15:33
@zlendo1 zlendo1 merged commit 52e44a7 into development Nov 13, 2025
2 checks passed
@3nd3r1 3nd3r1 deleted the copilot/update-routing-api-logic branch November 17, 2025 14: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.

Update the logic of the routing API fetching preferences

2 participants