Skip to content

fix : added order_id filter to driver telemetry MongoDB query - #792

Merged
KanishJebaMathewM merged 1 commit into
KanishJebaMathewM:mainfrom
tmdeveloper007:#787
Jun 26, 2026
Merged

fix : added order_id filter to driver telemetry MongoDB query#792
KanishJebaMathewM merged 1 commit into
KanishJebaMathewM:mainfrom
tmdeveloper007:#787

Conversation

@tmdeveloper007

@tmdeveloper007 tmdeveloper007 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Closes #787.

Summary of What Has Been Done:
Added an order_id filter to the MongoDB telemetry query in GET /orders/:id/driver-location. Previously the query returned telemetry for the driver regardless of which order it belonged to, causing stale location data to be shown when a driver has multiple active orders.

Changes Made:

  • backend/api/src/routes/orderRoutes.js: Changed the telemetry find() query from { driver_id: order.driver_id } to { driver_id: order.driver_id, order_id: order.id }.

Impact it Made:
All 239 unit tests pass. The driver location endpoint now correctly scopes telemetry to the specific order being tracked.

Summary by CodeRabbit

  • Bug Fixes
    • Improved driver location data retrieval so the app fetches telemetry specifically for the selected order, avoiding potentially unrelated location results.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution! Your pull request has been received and will be reviewed shortly.

If you enjoy the project, please consider giving the repository a ⭐. You can also follow my GitHub profile to stay updated on future open-source projects.

Thanks for being part of the community! 🚀

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

![Review Change Stack [link removed for security]]([link removed for security])

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c36f220-49bf-4456-bd1a-cd3bf27ebec5

📥 Commits

Reviewing files that changed from the base of the PR and between d99ada6 and 9211b21.

📒 Files selected for processing (1)
  • backend/api/src/routes/orderRoutes.js
💤 Files with no reviewable changes (1)
  • backend/api/src/routes/orderRoutes.js

📝 Walkthrough

Walkthrough

The MongoDB telemetry query inside the GET /:id/driver-location endpoint in orderRoutes.js is updated to filter by both driver_id and order_id (using order.id). Previously only driver_id was used, which could return telemetry from other orders.

Changes

Driver Telemetry Query Fix

Layer / File(s) Summary
Narrow telemetry query to order_id + driver_id
backend/api/src/routes/orderRoutes.js
The find() call in the driver-location endpoint now includes order_id: order.id alongside driver_id, restricting returned telemetry to records belonging to the specific order.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Possibly related PRs

Poem

🐇 Hop hop, the query was wide,
Returning old tracks from every ride.
I added order_id with a twitch of my nose,
Now only the right telemetry shows.
Correct locations, no stale data in sight — ✨
This little fix makes the tracking right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding an order_id filter to the driver telemetry MongoDB query in orderRoutes.js.
Linked Issues check ✅ Passed The PR fully implements the required fix from issue #787: adding order_id filter to the MongoDB telemetry query in orderRoutes.js, matching the current order's id against telemetry document's order_id field.
Out of Scope Changes check ✅ Passed All changes in the PR are directly scoped to the stated objective: modifying the telemetry query filter from {driver_id} to {driver_id, order_id} with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

⚠️ Security Notice: Links posted by non-contributors have been automatically removed.

@KanishJebaMathewM
KanishJebaMathewM merged commit 2edb62c into KanishJebaMathewM:main Jun 26, 2026
5 of 7 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution!

Your pull request has been merged successfully. We appreciate your work and look forward to your future contributions. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix : add order_id filter to driver telemetry query in orderRoutes.js

2 participants