@issue_types.concat %w[DiaryEntry DiaryComment User] if current_user.administrator?
@users = User.joins(:roles).where(:user_roles => { :role => current_user.roles.map(&:role) }).distinct
- @issues = Issue.where(:assigned_role => current_user.roles.map(&:role))
+ @issues = Issue.visible_to(current_user)
# If search
if params[:search_by_user] && params[:search_by_user].present?
end
def open_issues_count
- count = Issue.open.limit(100).size
+ count = Issue.visible_to(current_user).open.limit(100).size
if count > 99
content_tag(:span, "99+", :class => "count-number")
elsif count > 0
before_validation :set_reported_user
scope :with_status, ->(issue_status) { where(:status => statuses[issue_status]) }
+ scope :visible_to, ->(user) { where(:assigned_role => user.roles.map(&:role)) }
def read_reports
resolved_at.present? ? reports.where("updated_at < ?", resolved_at) : nil