From 37d4abc6ddc6164e087eaa6186a3c53dc9cf8c24 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 29 Jan 2019 12:01:56 +0100 Subject: [PATCH] Improved error handling and performance of escalation rebuild_all. --- app/models/ticket/escalation.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/ticket/escalation.rb b/app/models/ticket/escalation.rb index dd793a9dd..6b769c170 100644 --- a/app/models/ticket/escalation.rb +++ b/app/models/ticket/escalation.rb @@ -16,8 +16,10 @@ returns def self.rebuild_all state_list_open = Ticket::State.by_category(:open) - ticket_ids = Ticket.where(state_id: state_list_open).pluck(:id) + ticket_ids = Ticket.where(state_id: state_list_open).limit(20_000).pluck(:id) ticket_ids.each do |ticket_id| + next if !Ticket.exists?(ticket_id) + Ticket.find(ticket_id).escalation_calculation(true) end end