From d01dfce8cb94d6ca61d2e94bcef2b470a4f0aa26 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 3 Oct 2019 13:43:41 +0200 Subject: [PATCH] Removed unused sla get of ticket in Ticket.process_escalation to save system ressources of scheduler. --- app/models/ticket.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 00c1e76f2..fb97ae3f5 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -127,7 +127,7 @@ returns tickets = where(state_id: next_state_map.keys) .where('pending_time <= ?', Time.zone.now) - tickets.each do |ticket| + tickets.find_each(batch_size: 500) do |ticket| Transaction.execute do ticket.state_id = next_state_map[ticket.state_id] ticket.updated_at = Time.zone.now @@ -151,7 +151,7 @@ returns tickets = where(state_id: reminder_state_map.keys) .where('pending_time <= ?', Time.zone.now) - tickets.each do |ticket| + tickets.find_each(batch_size: 500) do |ticket| article_id = nil article = Ticket::Article.last_customer_agent_article(ticket.id) @@ -190,14 +190,8 @@ returns def self.process_escalation result = [] - # get max warning diff - - tickets = where('escalation_at <= ?', Time.zone.now + 15.minutes) - - tickets.each do |ticket| - - # get sla - ticket.escalation_calculation_get_sla + # fetch all escalated and soon to be escalating tickets + where('escalation_at <= ?', Time.zone.now + 15.minutes).find_each(batch_size: 500) do |ticket| article_id = nil article = Ticket::Article.last_customer_agent_article(ticket.id)