Improved performance - reduced sql queries.
This commit is contained in:
parent
38ee7f30f3
commit
65d9f58ebe
2 changed files with 11 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
require 'cache'
|
||||||
|
|
||||||
class Sla < ApplicationModel
|
class Sla < ApplicationModel
|
||||||
store :condition
|
store :condition
|
||||||
store :data
|
store :data
|
||||||
|
@ -9,6 +11,7 @@ class Sla < ApplicationModel
|
||||||
|
|
||||||
private
|
private
|
||||||
def escalation_calculation_rebuild
|
def escalation_calculation_rebuild
|
||||||
|
Cache.delete( 'SLA::List::Active' )
|
||||||
Ticket.escalation_calculation_rebuild
|
Ticket.escalation_calculation_rebuild
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,6 @@
|
||||||
require 'time_calculation'
|
require 'time_calculation'
|
||||||
|
require 'sla'
|
||||||
|
|
||||||
class Ticket < ApplicationModel
|
class Ticket < ApplicationModel
|
||||||
before_create :number_generate, :check_defaults
|
before_create :number_generate, :check_defaults
|
||||||
before_update :check_defaults
|
before_update :check_defaults
|
||||||
|
@ -478,7 +480,12 @@ class Ticket < ApplicationModel
|
||||||
def _escalation_calculation_get_sla
|
def _escalation_calculation_get_sla
|
||||||
|
|
||||||
sla_selected = nil
|
sla_selected = nil
|
||||||
Sla.where( :active => true ).each {|sla|
|
sla_list = Cache.get( 'SLA::List::Active' )
|
||||||
|
if sla_list == nil
|
||||||
|
sla_list = Sla.where( :active => true ).all
|
||||||
|
Cache.write( 'SLA::List::Active', sla_list, { :expires_in => 1.hour } )
|
||||||
|
end
|
||||||
|
sla_list.each {|sla|
|
||||||
if !sla.condition || sla.condition.empty?
|
if !sla.condition || sla.condition.empty?
|
||||||
sla_selected = sla
|
sla_selected = sla
|
||||||
elsif sla.condition
|
elsif sla.condition
|
||||||
|
|
Loading…
Reference in a new issue