diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-07-14 07:15:13 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-07-14 07:15:13 +0000 |
commit | d2f7e31951d0e150df9cfd6da7d91d855f734d5f (patch) | |
tree | 35dfd4e7ff86f66c9eacb5bec14c63e920913896 /app | |
parent | e58e676b7c15bb3f837f660f857d8e2a3e35f233 (diff) | |
download | redmine-d2f7e31951d0e150df9cfd6da7d91d855f734d5f.tar.gz redmine-d2f7e31951d0e150df9cfd6da7d91d855f734d5f.zip |
Use .distinct instead of .uniq.
git-svn-id: http://svn.redmine.org/redmine/trunk@15654 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/versions_controller.rb | 2 | ||||
-rw-r--r-- | app/models/issue_status.rb | 2 | ||||
-rw-r--r-- | app/models/journal.rb | 2 | ||||
-rw-r--r-- | app/models/member.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 8 | ||||
-rw-r--r-- | app/models/repository.rb | 2 | ||||
-rw-r--r-- | app/models/tracker.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 2 |
8 files changed, 12 insertions, 12 deletions
diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index fa9995198..e1684e3cf 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -38,7 +38,7 @@ class VersionsController < ApplicationController @versions = @project.shared_versions.preload(:custom_values) @versions += @project.rolled_up_versions.visible.preload(:custom_values) if @with_subprojects - @versions = @versions.uniq.sort + @versions = @versions.to_a.uniq.sort unless params[:completed] @completed_versions = @versions.select(&:completed?) @versions -= @completed_versions diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb index 31c0f031c..553c46bc5 100644 --- a/app/models/issue_status.rb +++ b/app/models/issue_status.rb @@ -66,7 +66,7 @@ class IssueStatus < ActiveRecord::Base end end - scope.uniq.to_a.sort + scope.distinct.to_a.sort else [] end diff --git a/app/models/journal.rb b/app/models/journal.rb index d65034c56..3f1a34952 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -40,7 +40,7 @@ class Journal < ActiveRecord::Base :scope => preload({:issue => :project}, :user). joins("LEFT OUTER JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id"). where("#{Journal.table_name}.journalized_type = 'Issue' AND" + - " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").uniq + " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct before_create :split_private_notes after_create :send_notification diff --git a/app/models/member.rb b/app/models/member.rb index 389684dab..0c6a8868e 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -19,7 +19,7 @@ class Member < ActiveRecord::Base belongs_to :user belongs_to :principal, :foreign_key => 'user_id' has_many :member_roles, :dependent => :destroy - has_many :roles, lambda {uniq}, :through => :member_roles + has_many :roles, lambda { distinct }, :through => :member_roles belongs_to :project validates_presence_of :principal, :project diff --git a/app/models/project.rb b/app/models/project.rb index c48c54855..ac204ebc1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -233,11 +233,11 @@ class Project < ActiveRecord::Base end def principals - @principals ||= Principal.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).uniq + @principals ||= Principal.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).distinct end def users - @users ||= User.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).uniq + @users ||= User.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).distinct end # Returns the Systemwide and project specific activities @@ -437,7 +437,7 @@ class Project < ActiveRecord::Base joins(projects: :enabled_modules). where("#{Project.table_name}.status <> ?", STATUS_ARCHIVED). where(:enabled_modules => {:name => 'issue_tracking'}). - uniq. + distinct. sorted end @@ -522,7 +522,7 @@ class Project < ActiveRecord::Base active. joins(:members => :roles). where(:type => types, :members => {:project_id => id}, :roles => {:assignable => true}). - uniq. + distinct. sorted if tracker diff --git a/app/models/repository.rb b/app/models/repository.rb index be1ea93d9..5f2f118b7 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -283,7 +283,7 @@ class Repository < ActiveRecord::Base # Returns an array of committers usernames and associated user_id def committers - @committers ||= Changeset.where(:repository_id => id).uniq.pluck(:committer, :user_id) + @committers ||= Changeset.where(:repository_id => id).distinct.pluck(:committer, :user_id) end # Maps committers username to a user ids diff --git a/app/models/tracker.rb b/app/models/tracker.rb index 5e4a24b51..41db78804 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -66,7 +66,7 @@ class Tracker < ActiveRecord::Base end end end - joins(:projects).where(condition).uniq + joins(:projects).where(condition).distinct } def to_s; name end @@ -85,7 +85,7 @@ class Tracker < ActiveRecord::Base if new_record? [] else - @issue_status_ids ||= WorkflowTransition.where(:tracker_id => id).uniq.pluck(:old_status_id, :new_status_id).flatten.uniq + @issue_status_ids ||= WorkflowTransition.where(:tracker_id => id).distinct.pluck(:old_status_id, :new_status_id).flatten.uniq end end diff --git a/app/models/user.rb b/app/models/user.rb index 0fc740520..69db92240 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -140,7 +140,7 @@ class User < Principal scope :having_mail, lambda {|arg| addresses = Array.wrap(arg).map {|a| a.to_s.downcase} if addresses.any? - joins(:email_addresses).where("LOWER(#{EmailAddress.table_name}.address) IN (?)", addresses).uniq + joins(:email_addresses).where("LOWER(#{EmailAddress.table_name}.address) IN (?)", addresses).distinct else none end |