diff --git a/app/controllers/admin/tickets_controller.rb b/app/controllers/admin/tickets_controller.rb index 5252e49..cc78ddc 100644 --- a/app/controllers/admin/tickets_controller.rb +++ b/app/controllers/admin/tickets_controller.rb @@ -50,15 +50,20 @@ class Admin::TicketsController < OrbitAdminController end def tagged_tickets - tqrs = TicketQueryResponse.where(:user_tags.in => [current_user.id.to_s], :read_by.nin => [current_user.id.to_s], :status.ne => "closed") + if params[:keywords].present? + statuses = ["open","commenced", "closed"] + else + statuses = ["open","commenced"] + end + tqrs = TicketQueryResponse.where(:user_tags.in => [current_user.id.to_s], :read_by.nin => [current_user.id.to_s]) @unread_tickets = [] @read_tickets = [] tqrs.each do |tqr| - @unread_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil? + @unread_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil? && statuses.include?(tqr.ticket_query.ticket.status) end - tqrs = TicketQueryResponse.where(:user_tags.in => [current_user.id.to_s], :read_by.in => [current_user.id.to_s], :status.ne => "closed") + tqrs = TicketQueryResponse.where(:user_tags.in => [current_user.id.to_s], :read_by.in => [current_user.id.to_s]) tqrs.each do |tqr| - @read_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil? + @read_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil? && statuses.include?(tqr.ticket_query.ticket.status) end @read_tickets.uniq! @unread_tickets.uniq! diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 7543fad..e1ccff9 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -50,7 +50,7 @@ class Ticket tqrs = TicketQueryResponse.where(:user_tags.in => [user.id.to_s], :read_by.nin => [user.id.to_s]) unread_tickets = [] tqrs.each do |tqr| - unread_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil? + unread_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil? && tqr.ticket_query.ticket.status != "closed" end unread_tickets.uniq! unread_tickets.count