Order issue reports by id
This commit is contained in:
parent
e241d1d938
commit
cb4060bb2e
3 changed files with 3 additions and 3 deletions
|
@ -11,7 +11,7 @@ module Issues
|
|||
def index
|
||||
@issue = Issue.visible_to(current_user).find(params[:issue_id])
|
||||
|
||||
user_ids = @issue.reports.order(:created_at => :desc).pluck(:user_id).uniq
|
||||
user_ids = @issue.reports.reorder(:created_at => :desc).pluck(:user_id).uniq
|
||||
@unique_reporters = {
|
||||
@issue.id => {
|
||||
:count => user_ids.size,
|
||||
|
|
|
@ -47,7 +47,7 @@ class IssuesController < ApplicationController
|
|||
|
||||
@unique_reporters_limit = 3
|
||||
@unique_reporters = @issues.each_with_object({}) do |issue, reporters|
|
||||
user_ids = issue.reports.order(:created_at => :desc).pluck(:user_id).uniq
|
||||
user_ids = issue.reports.reorder(:created_at => :desc).pluck(:user_id).uniq
|
||||
reporters[issue.id] = {
|
||||
:count => user_ids.size,
|
||||
:users => User.in_order_of(:id, user_ids.first(@unique_reporters_limit))
|
||||
|
|
|
@ -36,7 +36,7 @@ class Issue < ApplicationRecord
|
|||
belongs_to :user_resolved, :class_name => "User", :foreign_key => :resolved_by, :optional => true
|
||||
belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by, :optional => true
|
||||
|
||||
has_many :reports, :dependent => :destroy
|
||||
has_many :reports, -> { order(:id) }, :dependent => :destroy
|
||||
has_many :comments, :class_name => "IssueComment", :dependent => :destroy
|
||||
|
||||
validates :reportable_id, :uniqueness => { :scope => [:reportable_type] }
|
||||
|
|
Loading…
Add table
Reference in a new issue