Commit 55a184bf61313a003a6e25f19e40a66b0d35d115

Authored by Austin Smith
1 parent c2b5757436
Exists in master

remove unnecessary coalesce

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

app/controllers/my_taskboard_controller.rb View file @ 55a184b
class MyTaskboardController < ApplicationController 1 1 class MyTaskboardController < ApplicationController
unloadable 2 2 unloadable
3 3
before_filter :my_account_or_admin 4 4 before_filter :my_account_or_admin
5 5
def my_index 6 6 def my_index
index 7 7 index
render 'index' 8 8 render 'index'
end 9 9 end
10 10
def index 11 11 def index
issues = Issue.select( \ 12 12 issues = Issue.select( \
"issues.id, 13 13 "issues.id,
issues.subject, 14 14 issues.subject,
issues.status_id, 15 15 issues.status_id,
projects.name as project_name, 16 16 projects.name as project_name,
trackers.name as tracker_name, 17 17 trackers.name as tracker_name,
issue_priority.name as priority_name, 18 18 issue_priority.name as priority_name,
issue_priority.id as priority_id, 19 19 issue_priority.id as priority_id,
projects.id as project_id, 20 20 projects.id as project_id,
COALESCE(tba.weight, 0) as weight, 21 21 tba.weight,
issue_statuses.name as status_name, 22 22 issue_statuses.name as status_name,
tba.issue_id" 23 23 tba.issue_id"
) \ 24 24 ) \
.joins('LEFT OUTER JOIN task_board_assignees AS tba ON tba.issue_id = issues.id AND tba.assignee_id = issues.assigned_to_id') \ 25 25 .joins('LEFT OUTER JOIN task_board_assignees AS tba ON tba.issue_id = issues.id AND tba.assignee_id = issues.assigned_to_id') \
.joins('INNER JOIN issue_statuses ON issues.status_id = issue_statuses.id') \ 26 26 .joins('INNER JOIN issue_statuses ON issues.status_id = issue_statuses.id') \
.joins('INNER JOIN trackers ON trackers.id = issues.tracker_id') \ 27 27 .joins('INNER JOIN trackers ON trackers.id = issues.tracker_id') \
.joins('INNER JOIN projects ON projects.id = issues.project_id') \ 28 28 .joins('INNER JOIN projects ON projects.id = issues.project_id') \
.joins('INNER JOIN enumerations issue_priority ON issues.priority_id = issue_priority.id') \ 29 29 .joins('INNER JOIN enumerations issue_priority ON issues.priority_id = issue_priority.id') \
.where("assigned_to_id = ? AND issue_statuses.is_closed = 0 AND projects.status = 1", @user.id) \ 30 30 .where("assigned_to_id = ? AND issue_statuses.is_closed = 0 AND projects.status = 1", @user.id) \
.order("weight ASC, issue_priority.position DESC") 31 31 .order("weight ASC, issue_priority.position DESC")
@not_prioritized = Array.new 32 32 @not_prioritized = Array.new
@prioritized = Array.new 33 33 @prioritized = Array.new
34 34
issues.each do |issue| 35 35 issues.each do |issue|
if issue.weight == nil or issue.weight == 0 36 36 if issue.weight == nil or issue.weight == 0
@not_prioritized << issue 37 37 @not_prioritized << issue
else 38 38 else
@prioritized << issue 39 39 @prioritized << issue
end 40 40 end
end 41 41 end
end 42 42 end
43 43
def save 44 44 def save
TaskBoardAssignee.destroy_all(:assignee_id => @user.id) 45 45 TaskBoardAssignee.destroy_all(:assignee_id => @user.id)
weight = 1; 46 46 weight = 1;
params[:sort].each do |issue_id| 47 47 params[:sort].each do |issue_id|
TaskBoardAssignee.create(:issue_id => issue_id, :assignee_id => @user.id, :weight => weight) 48 48 TaskBoardAssignee.create(:issue_id => issue_id, :assignee_id => @user.id, :weight => weight)
weight += 1 49 49 weight += 1
end 50 50 end
respond_to do |format| 51 51 respond_to do |format|
format.js{ head :ok } 52 52 format.js{ head :ok }
end 53 53 end
end 54 54 end
55 55
def my_account_or_admin 56 56 def my_account_or_admin
find_user 57 57 find_user
if @user.id != User.current.id 58 58 if @user.id != User.current.id
require_admin 59 59 require_admin
end 60 60 end
true 61 61 true
end 62 62 end
63 63
def find_user 64 64 def find_user
if params[:id] == nil 65 65 if params[:id] == nil
params[:id] = User.current.id 66 66 params[:id] = User.current.id
end 67 67 end
68 68
if params[:id] == 'current' 69 69 if params[:id] == 'current'
require_login || return 70 70 require_login || return
@user = User.current 71 71 @user = User.current