app/models/foreman_tasks/task.rb in foreman-tasks-0.10.1 vs app/models/foreman_tasks/task.rb in foreman-tasks-0.10.2

- old
+ new

@@ -49,11 +49,11 @@ :on => :id, :complete_value => true, :rename => 'owner.id', :ext_method => :search_by_owner, :validator => ->(value) { ScopedSearch::Validators::INTEGER.call(value) || value == 'current_user' } - scoped_search :relation => :owners, :on => :login, :complete_value => true, :rename => 'owner.login', :ext_method => :search_by_owner + scoped_search :relation => :owners, :on => :login, :complete_value => true, :rename => 'owner.login', :ext_method => :search_by_owner, :aliases => [:user] scoped_search :relation => :owners, :on => :firstname, :complete_value => true, :rename => 'owner.firstname', :ext_method => :search_by_owner scoped_search :relation => :task_groups, :on => :id, :complete_value => true, :rename => 'task_group.id', :validator => ScopedSearch::Validators::INTEGER scope :active, -> { where('foreman_tasks_tasks.state != ?', :stopped) } scope :running, -> { where("foreman_tasks_tasks.state NOT IN ('stopped', 'paused')") } @@ -131,10 +131,11 @@ end def self.search_by_owner(key, operator, value) return { :conditions => '0 = 1' } if value == 'current_user' && User.current.nil? + key = 'owners.login' if key == 'user' key_name = connection.quote_column_name(key.sub(/^.*\./, '')) joins = <<-SQL INNER JOIN foreman_tasks_locks AS foreman_tasks_locks_owner ON (foreman_tasks_locks_owner.task_id = foreman_tasks_tasks.id AND foreman_tasks_locks_owner.resource_type = 'User' AND @@ -174,9 +175,10 @@ end def add_missing_task_groups(groups) groups = [groups] unless groups.is_a? Array (groups - task_groups).each { |group| task_groups << group } + save! end def sub_tasks_counts result = %w[cancelled error pending success warning].inject({}) do |hash, state| hash.update(state => 0)