diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2014-10-24 02:18:45 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2014-10-24 02:18:45 +0000 |
commit | 6f92548b38ab1f651b20b4b0696f0aee28eb430b (patch) | |
tree | 6944e071a19bc2dda0e0d57ccb4a17d1cbc4b211 /app | |
parent | 374f4dd52e1370db0e60e2bc035513c7cd5bb8fa (diff) | |
download | redmine-6f92548b38ab1f651b20b4b0696f0aee28eb430b.tar.gz redmine-6f92548b38ab1f651b20b4b0696f0aee28eb430b.zip |
remove unneeded "references" of joins
"references" is needed for includes, but not needed for joins.
git-svn-id: http://svn.redmine.org/redmine/trunk@13501 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/boards_controller.rb | 1 | ||||
-rw-r--r-- | app/helpers/my_helper.rb | 1 | ||||
-rw-r--r-- | app/models/board.rb | 1 | ||||
-rw-r--r-- | app/models/changeset.rb | 1 | ||||
-rw-r--r-- | app/models/document.rb | 1 | ||||
-rw-r--r-- | app/models/group.rb | 1 | ||||
-rw-r--r-- | app/models/issue.rb | 5 | ||||
-rw-r--r-- | app/models/issue_query.rb | 1 | ||||
-rw-r--r-- | app/models/journal.rb | 1 | ||||
-rw-r--r-- | app/models/message.rb | 1 | ||||
-rw-r--r-- | app/models/news.rb | 1 | ||||
-rw-r--r-- | app/models/project.rb | 6 | ||||
-rw-r--r-- | app/models/time_entry.rb | 3 | ||||
-rw-r--r-- | app/models/version.rb | 1 |
14 files changed, 0 insertions, 25 deletions
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 04bdb56c0..c1ac10c4f 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -46,7 +46,6 @@ class BoardsController < ApplicationController @topics = @board.topics. reorder("#{Message.table_name}.sticky DESC"). joins("LEFT OUTER JOIN #{Message.table_name} last_replies_messages ON last_replies_messages.id = #{Message.table_name}.last_reply_id"). - references(:last_reply). limit(@topic_pages.per_page). offset(@topic_pages.offset). order(sort_clause). diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb index 5917f26ec..5e826886a 100644 --- a/app/helpers/my_helper.rb +++ b/app/helpers/my_helper.rb @@ -69,7 +69,6 @@ module MyHelper TimeEntry. where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, Date.today - 6, Date.today). joins(:activity, :project, {:issue => [:tracker, :status]}). - references(:activity, :project, {:issue => [:tracker, :status]}). order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC"). to_a end diff --git a/app/models/board.rb b/app/models/board.rb index 7e2507d8b..70d3cb2e5 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -32,7 +32,6 @@ class Board < ActiveRecord::Base scope :visible, lambda {|*args| joins(:project). - references(:project). where(Project.allowed_to_condition(args.shift || User.current, :view_messages, *args)) } diff --git a/app/models/changeset.rb b/app/models/changeset.rb index d75244166..c54ad0bc3 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -50,7 +50,6 @@ class Changeset < ActiveRecord::Base scope :visible, lambda {|*args| joins(:repository => :project). - references(:repository => :project). where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args)) } diff --git a/app/models/document.rb b/app/models/document.rb index 00530131a..70e3c9b01 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -36,7 +36,6 @@ class Document < ActiveRecord::Base scope :visible, lambda {|*args| joins(:project). - references(:project). where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args)) } diff --git a/app/models/group.rb b/app/models/group.rb index b9d4d9ef4..a7a17edb8 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -83,7 +83,6 @@ class Group < Principal members.each do |member| MemberRole. joins(:member). - references(:member). where("#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids). each(&:destroy) end diff --git a/app/models/issue.rb b/app/models/issue.rb index d50d755d4..8bdfda836 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -85,14 +85,12 @@ class Issue < ActiveRecord::Base scope :open, lambda {|*args| is_closed = args.size > 0 ? !args.first : false joins(:status). - references(:status). where("#{IssueStatus.table_name}.is_closed = ?", is_closed) } scope :recently_updated, lambda { order("#{Issue.table_name}.updated_on DESC") } scope :on_active_project, lambda { joins(:project). - references(:project). where("#{Project.table_name}.status = ?", Project::STATUS_ACTIVE) } scope :fixed_version, lambda {|versions| @@ -891,11 +889,9 @@ class Issue < ActiveRecord::Base issue_ids = issues.map(&:id) # Relations with issue_from in given issues and visible issue_to relations_from = IssueRelation.joins(:issue_to => :project). - references(:issue_to => :project). where(visible_condition(user)).where(:issue_from_id => issue_ids).to_a # Relations with issue_to in given issues and visible issue_from relations_to = IssueRelation.joins(:issue_from => :project). - references(:issue_from => :project). where(visible_condition(user)). where(:issue_to_id => issue_ids).to_a issues.each do |issue| @@ -1440,7 +1436,6 @@ class Issue < ActiveRecord::Base # Only need to update issues with a fixed_version from # a different project and that is not systemwide shared Issue.joins(:project, :fixed_version). - references(:version, :fixed_version). where("#{Issue.table_name}.fixed_version_id IS NOT NULL" + " AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" + " AND #{Version.table_name}.sharing <> 'system'"). diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 9ca0f3077..15c49c5d6 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -46,7 +46,6 @@ class IssueQuery < Query user = args.shift || User.current base = Project.allowed_to_condition(user, :view_issues, *args) scope = joins("LEFT OUTER JOIN #{Project.table_name} ON #{table_name}.project_id = #{Project.table_name}.id"). - references(:project). where("#{table_name}.project_id IS NULL OR (#{base})") if user.admin? diff --git a/app/models/journal.rb b/app/models/journal.rb index 543da42b8..770e98585 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -46,7 +46,6 @@ class Journal < ActiveRecord::Base scope :visible, lambda {|*args| user = args.shift || User.current joins(:issue => :project). - references(:project). where(Issue.visible_condition(user, *args)). where("(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(user, :view_private_notes, *args)}))", false) } diff --git a/app/models/message.rb b/app/models/message.rb index a5540d953..dee5a5b62 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -50,7 +50,6 @@ class Message < ActiveRecord::Base scope :visible, lambda {|*args| joins(:board => :project). - references(:board => :project). where(Project.allowed_to_condition(args.shift || User.current, :view_messages, *args)) } diff --git a/app/models/news.rb b/app/models/news.rb index 59411bd44..65a22c66f 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -39,7 +39,6 @@ class News < ActiveRecord::Base scope :visible, lambda {|*args| joins(:project). - references([:author, :project]). where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args)) } diff --git a/app/models/project.rb b/app/models/project.rb index 92bbf0e88..89d4a5297 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -30,12 +30,10 @@ class Project < ActiveRecord::Base has_many :time_entry_activities has_many :members, lambda { joins(:principal, :roles). - references(:principal, :roles). where("#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}") } has_many :memberships, :class_name => 'Member' has_many :member_principals, lambda { joins(:principal). - references(:principal). where("#{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}")}, :class_name => 'Member' has_many :enabled_modules, :dependent => :delete_all @@ -438,7 +436,6 @@ class Project < ActiveRecord::Base @rolled_up_trackers ||= Tracker. joins(:projects). - references(:project). joins("JOIN #{EnabledModule.table_name} ON #{EnabledModule.table_name}.project_id = #{Project.table_name}.id AND #{EnabledModule.table_name}.name = 'issue_tracking'"). select("DISTINCT #{Tracker.table_name}.*"). where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> #{STATUS_ARCHIVED}", lft, rgt). @@ -462,7 +459,6 @@ class Project < ActiveRecord::Base @rolled_up_versions ||= Version. joins(:project). - references(:project). where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> ?", lft, rgt, STATUS_ARCHIVED) end @@ -471,7 +467,6 @@ class Project < ActiveRecord::Base if new_record? Version. joins(:project). - references(:project). preload(:project). where("#{Project.table_name}.status <> ? AND #{Version.table_name}.sharing = 'system'", STATUS_ARCHIVED) else @@ -479,7 +474,6 @@ class Project < ActiveRecord::Base r = root? ? self : root Version. joins(:project). - references(:project). preload(:project). where("#{Project.table_name}.id = #{id}" + " OR (#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND (" + diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 80112308a..240df7556 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -46,17 +46,14 @@ class TimeEntry < ActiveRecord::Base scope :visible, lambda {|*args| joins(:project). - references(:project). where(Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args)) } scope :on_issue, lambda {|issue| joins(:issue). - references(:issue). where("#{Issue.table_name}.root_id = #{issue.root_id} AND #{Issue.table_name}.lft >= #{issue.lft} AND #{Issue.table_name}.rgt <= #{issue.rgt}") } scope :on_project, lambda {|project, include_subprojects| joins(:project). - references(:project). where(project.project_condition(include_subprojects)) } scope :spent_between, lambda {|from, to| diff --git a/app/models/version.rb b/app/models/version.rb index 878c611ed..214a987ad 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -39,7 +39,6 @@ class Version < ActiveRecord::Base scope :open, lambda { where(:status => 'open') } scope :visible, lambda {|*args| joins(:project). - references(:project). where(Project.allowed_to_condition(args.first || User.current, :view_issues)) } |