diff --git a/app/models/ticket/state.rb b/app/models/ticket/state.rb index af94bf33c..1b9939ab6 100644 --- a/app/models/ticket/state.rb +++ b/app/models/ticket/state.rb @@ -32,7 +32,7 @@ returns: ) elsif category == 'work_on' return Ticket::State.where( - state_type_id: Ticket::StateType.where( name: ['new', 'open'] ) + state_type_id: Ticket::StateType.where( name: %w(new open) ) ) elsif category == 'work_on_all' return Ticket::State.where( @@ -40,7 +40,7 @@ returns: ) elsif category == 'closed' return Ticket::State.where( - state_type_id: Ticket::StateType.where( name: ['closed'] ) + state_type_id: Ticket::StateType.where( name: %w(closed) ) ) end fail "Unknown category '#{category}'" diff --git a/lib/stats.rb b/lib/stats.rb index 7b5e61777..ac5dddd99 100644 --- a/lib/stats.rb +++ b/lib/stats.rb @@ -43,9 +43,9 @@ returns # calculate average backend_average_sum = {} - user_result.each {|user_id, data| + user_result.each {|_user_id, data| data.each {|backend_model, backend_result| - next if !backend_result.has_key?(:used_for_average) + next if !backend_result.key?(:used_for_average) if !backend_average_sum[backend_model] backend_average_sum[backend_model] = 0 end @@ -56,10 +56,10 @@ returns # generate average stats backend_average_sum.each {|backend_model_average, result| average = ( result.to_f / agent_count.to_f ).round(1) - user_result.each {|user_id, data| + user_result.each {|_user_id, data| data.each {|backend_model_data, backend_result| next if backend_model_data != backend_model_average - next if !backend_result.has_key?(:used_for_average) + next if !backend_result.key?(:used_for_average) backend_result[:average_per_agent] = average } } diff --git a/lib/stats/ticket_in_process.rb b/lib/stats/ticket_in_process.rb index aaa7ecb96..a17270b11 100644 --- a/lib/stats/ticket_in_process.rb +++ b/lib/stats/ticket_in_process.rb @@ -20,14 +20,14 @@ class Stats::TicketInProcess closed_state_ids = Ticket::State.by_category('closed').map(&:id) closed_ticket_ids = Ticket.select('id').where( 'owner_id = ? AND state_id IN (?) AND close_time > ?', - user.id, closed_state_ids, Time.zone.now-1.day + user.id, closed_state_ids, Time.zone.now - 1.day ).limit(100).map(&:id) # get all tickets which I changed to pending action pending_action_state_ids = Ticket::State.by_category('pending_action').map(&:id) pending_action_ticket_ids = Ticket.select('id').where( 'owner_id = ? AND state_id IN (?) AND updated_at > ?', - user.id, pending_action_state_ids, Time.zone.now-1.day + user.id, pending_action_state_ids, Time.zone.now - 1.day ).limit(100).map(&:id) all_ticket_ids = own_ticket_ids.concat(closed_ticket_ids).concat(pending_action_ticket_ids).uniq