Improved related ticket, if we do not have open related tickets, search for any tickets of the customer.

This commit is contained in:
Martin Edenhofer 2016-06-08 15:25:39 +02:00
parent 3306cf4e8a
commit 8051c1c741

View file

@ -201,6 +201,18 @@ class TicketsController < ApplicationController
.order('created_at DESC') .order('created_at DESC')
.limit(6) .limit(6)
# if we do not have open related tickets, search for any tickets
if ticket_lists.empty?
ticket_lists = Ticket
.where(
customer_id: ticket.customer_id,
)
.where(access_condition)
.where('id != ?', [ ticket.id ])
.order('created_at DESC')
.limit(6)
end
# get related assets # get related assets
ticket_ids_by_customer = [] ticket_ids_by_customer = []
ticket_lists.each {|ticket_list| ticket_lists.each {|ticket_list|