Add ordering by creation date to user connection queries#1704
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo query methods in the custom connection repository now sort results by creation date in descending order. Existing filtering logic for user ID matching and test connection flags remains unchanged. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds explicit ordering to user connection retrieval queries so connection lists are returned in descending creation time, aligning API output with “newest first” expectations.
Changes:
- Order
findAllUserConnectionsresults byconnection.createdAt DESC. - Order
findAllUserTestConnectionsresults byconnection.createdAt DESC.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .leftJoinAndSelect('connection.connection_properties', 'connection_properties') | ||
| .andWhere('user.id = :userId', { userId: userId }); | ||
| .andWhere('user.id = :userId', { userId: userId }) | ||
| .orderBy('connection.createdAt', 'DESC'); |
There was a problem hiding this comment.
Ordering solely by createdAt can be nondeterministic when multiple connections share the same timestamp (e.g., bulk inserts / same DB transaction timestamp). Consider adding a secondary deterministic sort key (via addOrderBy) to ensure stable results when createdAt ties.
| .andWhere('user.id = :userId', { userId: userId }) | ||
| .andWhere('connection.isTestConnection = :isTest', { isTest: true }); | ||
| .andWhere('connection.isTestConnection = :isTest', { isTest: true }) | ||
| .orderBy('connection.createdAt', 'DESC'); |
There was a problem hiding this comment.
Same as above: ordering only by createdAt can produce unstable ordering when timestamps tie. Add a secondary deterministic ordering (e.g., addOrderBy) here as well so test-connection lists are stable.
| .andWhere('user.id = :userId', { userId: userId }) | ||
| .orderBy('connection.createdAt', 'DESC'); |
There was a problem hiding this comment.
This change introduces a user-visible ordering contract (newest connections first) but existing e2e tests around GET /connections don’t appear to assert ordering. Adding/adjusting an e2e assertion would prevent regressions (especially around test vs non-test connections).
Summary by CodeRabbit