Skip to content

[Bug]: Driver location endpoint returns stale/off-order telemetry due to missing order_id filter in MongoDB query#843

Merged
KanishJebaMathewM merged 1 commit into
KanishJebaMathewM:mainfrom
vipul674:fix/driver-location-order-filter-745
Jun 24, 2026
Merged

[Bug]: Driver location endpoint returns stale/off-order telemetry due to missing order_id filter in MongoDB query#843
KanishJebaMathewM merged 1 commit into
KanishJebaMathewM:mainfrom
vipul674:fix/driver-location-order-filter-745

Conversation

@vipul674

@vipul674 vipul674 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Fix

Added order_id: order.id to the MongoDB telemetry filter so the driver location endpoint returns GPS data from the correct order, not a stale or unrelated trip.

Changes

backend/api/src/routes/orderRoutes.js (line 1231)

  • Added order_id: order.id to the MongoDB .find() filter alongside existing driver_id filter

Closes #745

Summary by CodeRabbit

  • Bug Fixes
    • Improved driver location lookups so the app now matches telemetry by both driver and order, helping return the correct live location for each order.
    • Updated endpoint labeling in the route documentation to stay aligned with the current flow.

@vipul674

Copy link
Copy Markdown
Contributor Author

@KanishJebaMathewM I have submitted the fix. Please let me know if any changes are needed!

@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 24, 2026

Copy link
Copy Markdown

Review Change Stack

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: 68bce238-b205-4ac0-8e3b-05de5069fe81

📥 Commits

Reviewing files that changed from the base of the PR and between 5bf5e07 and d5ed78b.

📒 Files selected for processing (1)
  • backend/api/src/routes/orderRoutes.js

📝 Walkthrough

Walkthrough

The MongoDB query in the "GET DRIVER LOCATION" route is updated to filter telemetry documents by both driver_id and order_id, instead of driver_id alone. A section comment number is also corrected from 17 to 19.

Changes

Driver Location Telemetry Query Fix

Layer / File(s) Summary
Telemetry filter and comment correction
backend/api/src/routes/orderRoutes.js
Section comment renumbered from 17 to 19; MongoDB find filter on the telemetry collection extended to include order_id alongside driver_id, so only telemetry records belonging to the specific order are returned.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

  • #745 — This PR directly implements the fix described in the issue: adding order_id to the MongoDB telemetry filter in the driver-location endpoint to prevent stale or cross-order GPS data from being returned.
  • fix : add order_id filter to driver telemetry query in orderRoutes.js #787 — Also describes the same root cause (missing order_id filter in the telemetry query) and is addressed by this change.

Possibly related PRs

  • KanishJebaMathewM/Truxify#631: Directly related — modifies the same orderRoutes.js driver-location telemetry endpoint and MongoDB query logic.

Suggested labels

level:intermediate

Poem

🐇 Hippity-hop, the query's now tight,
No more wrong coords sending trackers astray!
With order_id added, the telemetry's right,
Each parcel's location accounted today.
The rabbit rejoices — no stale GPS in sight! 🗺️

🚥 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 describes the driver-location telemetry bug and the added order_id filter fix.
Linked Issues check ✅ Passed The PR matches issue #745 by filtering telemetry on both driver_id and order_id for the requested order.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to the telemetry query and a comment renumbering, with no unrelated edits.
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.

@KanishJebaMathewM KanishJebaMathewM merged commit 92418d9 into KanishJebaMathewM:main Jun 24, 2026
7 of 9 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.

[Bug]: Driver location endpoint returns stale/off-order telemetry due to missing order_id filter in MongoDB query

2 participants