Skip to content

Add ordering by creation date to user connection queries#1704

Merged
Artuomka merged 1 commit into
mainfrom
backend_default_connecion_order
Apr 6, 2026
Merged

Add ordering by creation date to user connection queries#1704
Artuomka merged 1 commit into
mainfrom
backend_default_connecion_order

Conversation

@Artuomka

@Artuomka Artuomka commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Connection lists now sorted by creation date in reverse chronological order.

Copilot AI review requested due to automatic review settings April 6, 2026 09:53
@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cfb58049-3324-4209-94dd-b05b3575b17b

📥 Commits

Reviewing files that changed from the base of the PR and between 520c80f and a86a95f.

📒 Files selected for processing (1)
  • backend/src/entities/connection/repository/custom-connection-repository-extension.ts

📝 Walkthrough

Walkthrough

Two 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

Cohort / File(s) Summary
Query Sorting Enhancement
backend/src/entities/connection/repository/custom-connection-repository-extension.ts
Added descending sort by connection.createdAt to findAllUserConnections and findAllUserTestConnections query builders.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Connections sorted, newest first,
A chronological burst!
Created dates in order flow,
The freshest links now steal the show!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding ordering by creation date to user connection queries, which matches the file summary showing new sorting by connection.createdAt in descending order.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Security Check ✅ Passed Adding orderBy clauses to findAllUserConnections and findAllUserTestConnections methods does not introduce OWASP security vulnerabilities. TypeORM query builders use parameterized queries preventing SQL injection, existing access control filters remain unchanged, and sorting does not expose sensitive information or bypass authentication.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_default_connecion_order

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.

❤️ Share

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

@Artuomka Artuomka enabled auto-merge April 6, 2026 09:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 findAllUserConnections results by connection.createdAt DESC.
  • Order findAllUserTestConnections results by connection.createdAt DESC.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 41 to +43
.leftJoinAndSelect('connection.connection_properties', 'connection_properties')
.andWhere('user.id = :userId', { userId: userId });
.andWhere('user.id = :userId', { userId: userId })
.orderBy('connection.createdAt', 'DESC');

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 57 to +59
.andWhere('user.id = :userId', { userId: userId })
.andWhere('connection.isTestConnection = :isTest', { isTest: true });
.andWhere('connection.isTestConnection = :isTest', { isTest: true })
.orderBy('connection.createdAt', 'DESC');

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +43
.andWhere('user.id = :userId', { userId: userId })
.orderBy('connection.createdAt', 'DESC');

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
@Artuomka Artuomka merged commit ce7071e into main Apr 6, 2026
22 of 24 checks passed
@Artuomka Artuomka deleted the backend_default_connecion_order branch April 6, 2026 10:04
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.

2 participants