app/models/foreman_tasks/task.rb in foreman-tasks-0.6.7 vs app/models/foreman_tasks/task.rb in foreman-tasks-0.6.8

- old
+ new

@@ -71,10 +71,11 @@ def paused? self.state == 'paused' end def self.search_by_generic_resource(key, operator, value) + key = "resource_type" if key.blank? key_name = self.connection.quote_column_name(key.sub(/^.*\./,'')) condition = sanitize_sql_for_conditions(["foreman_tasks_locks.#{key_name} #{operator} ?", value]) return {:conditions => condition, :joins => :locks } end @@ -87,10 +88,15 @@ foreman_tasks_locks_owner.resource_type = 'User' AND foreman_tasks_locks_owner.name = '#{Lock::OWNER_LOCK_NAME}') INNER JOIN users ON (users.id = foreman_tasks_locks_owner.resource_id) JOINS - condition = sanitize_sql_for_conditions(["users.#{key_name} #{operator} ?", value]) + + condition = if key.blank? + sanitize_sql_for_conditions(["users.login #{operator} ? or users.firstname #{operator} ? ", value, value]) + else + sanitize_sql_for_conditions(["users.#{key_name} #{operator} ?", value]) + end return {:conditions => condition, :joins => joins } end def progress case self.state.to_s