Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes implicit order(...) clauses from several ActiveRecord scopes and updates call sites to apply ordering explicitly where needed, aiming to avoid “hidden” ordering behavior in model scopes.
Changes:
- Removed ordering from
StatusMessagescopes (including deletingnewest) and added explicitorder(created_at: :desc)at updated call sites. - Removed
Comment.newest_firstand replaced its usage with explicit ordering. - Removed
Package.order_by_nameand updated the one call site to no longer use it.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/api/app/models/status_message.rb |
Removes ordering from announcements scope; adds explicit ordering in latest_for_current_user. |
src/api/app/models/package.rb |
Removes order_by_name scope. |
src/api/app/models/comment.rb |
Removes newest_first scope. |
src/api/app/controllers/webui/users_controller.rb |
Replaces newest_first scope usage with explicit order(created_at: :desc). |
src/api/app/controllers/webui/status_messages_controller.rb |
Replaces newest scope usage with explicit order(created_at: :desc). |
src/api/app/controllers/webui/projects/rebuild_times_controller.rb |
Stops using order_by_name when building package lists. |
src/api/app/controllers/webui/main_controller.rb |
Replaces newest scope usage with explicit order(created_at: :desc). |
src/api/app/controllers/webui/feeds_controller.rb |
Replaces newest scope usage with explicit order(created_at: :desc). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
order clause from scopesorder clause from scopes
krauselukas
reviewed
Apr 8, 2026
|
|
||
| validates :severity, :message, presence: true | ||
|
|
||
| scope :announcements, -> { order(created_at: :desc).where(severity: 'announcement') } |
Contributor
There was a problem hiding this comment.
@eduardoj I think you need to add order(created_at: :desc) here as well
Member
Author
There was a problem hiding this comment.
@krauselukas same issue reported by Copilot, better solution. I added the missing order clause. Thanks!
It is used only once, in a query where the order of the packages returned doesn't matter.
It is used only once. It can be replaced with the `order` clause.
7b87103 to
0a68033
Compare
It contains only an `order` clause. It can be easily replaced by the `order` clause. The `newest` name is also misleading: the scope doesn't return the newest record.
0a68033 to
1ffa05e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.