try fix freezing issue

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1171 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
rkh 15 years ago
parent 81d6d83f12
commit cf5261915c
  1. 16
      app/models/cost_query/sql_statement.rb

@ -49,15 +49,13 @@ class CostQuery::SqlStatement
# @return [CostQuery::SqlStatement] Generated statement # @return [CostQuery::SqlStatement] Generated statement
def self.unified_entry(model) def self.unified_entry(model)
table = table_name_for model table = table_name_for model
Rails.cache.fetch("unified_#{table}") do new(table).tap do |query|
new(table).tap do |query| query.select COMMON_FIELDS
query.select COMMON_FIELDS query.select({
query.select({ :type => model.model_name.inspect, :count => 1, :id => [model, :id],
:type => model.model_name.inspect, :count => 1, :id => [model, :id], :real_costs => switch("#{table}.overridden_costs IS NULL" => [model, :costs], :else => [model, :overridden_costs])
:real_costs => switch("#{table}.overridden_costs IS NULL" => [model, :costs], :else => [model, :overridden_costs]) })
}) send("unify_#{table}", query)
send("unify_#{table}", query)
end
end end
end end

Loading…
Cancel
Save