Patch #14318 » 0001-Fix-query-error-where-no-issue_ids-are-watched-or-fo.patch
| app/models/issue.rb | ||
|---|---|---|
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||
|
when 'own_watch'
|
||
|
user_ids = [user.id] + user.groups.pluck(:id).compact
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}) OR #{table_name}.id IN (#{Watcher.where(user_id: user.id, watchable_type: 'Issue').pluck(:watchable_id).compact.join(',')}))"
|
||
|
text_other_ids = Watcher.where(user_id: user.id, watchable_type: 'Issue').pluck(:watchable_id).compact.join(',')
|
||
|
text_other_ids = "OR #{table_name}.id IN (#{text_other_ids})" if text_other_ids.present?
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}) #{text_other_ids})"
|
||
|
when 'own_watch_contributed'
|
||
|
user_ids = [user.id] + user.groups.pluck(:id).compact
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}) OR #{table_name}.id IN (#{Watcher.where(user_id: user.id, watchable_type: 'Issue').pluck(:watchable_id).compact.join(',')}) OR #{table_name}.id IN (#{Journal.where(user_id: user.id, journalized_type: 'Issue').group(:journalized_id).pluck(:journalized_id).compact.join(',')}))"
|
||
|
text_other_ids = (Watcher.where(user_id: user.id, watchable_type: 'Issue').pluck(:watchable_id) + Journal.where(user_id: user.id, journalized_type: 'Issue').group(:journalized_id).pluck(:journalized_id)).compact.join(',')
|
||
|
text_other_ids = "OR #{table_name}.id IN (#{text_other_ids})" if text_other_ids.present?
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}) #{text_other_ids})"
|
||
|
else
|
||
|
'1=0'
|
||
|
end
|
||