Project

General

Profile

Feature #11724 » 0001-watchers-fix.patch

Rafał Lisowski, 2014-04-15 22:18

View differences:

app/controllers/watchers_controller.rb
40 40
    else
41 41
      user_ids << params[:user_id]
42 42
    end
43
    user_ids.flatten.compact.uniq.each do |user_id|
43
    user_ids = user_ids.flatten.compact.uniq.map(&:to_i) & users_for_new_watcher.map(&:id)
44
    user_ids.each do |user_id|
44 45
      Watcher.create(:watchable => @watched, :user_id => user_id)
45 46
    end
46 47
    respond_to do |format|
......
116 117

  
117 118
  def users_for_new_watcher
118 119
    users = []
119
    if params[:q].blank? && @project.present?
120
      users = @project.users.sorted
121
    else
122
      users = User.active.sorted.like(params[:q]).limit(100)
120
    if @project.present?
121
      if params[:q].blank?
122
        users = @project.users.sorted
123
      else
124
        users = @project.users.sorted.like(params[:q]).limit(10)
125
      end
123 126
    end
124 127
    if @watched
125 128
      users -= @watched.watcher_users
    (1-1/1)