From 1b9bb59cf7d12b9387aed5934f6f0db15bff5f3e Mon Sep 17 00:00:00 2001 From: jwollert Date: Thu, 21 Apr 2011 12:55:48 +0200 Subject: [PATCH] fix broken Report#cache_key method, needs to be independent filter order --- lib/report.rb | 2 +- lib/report/filter/base.rb | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/report.rb b/lib/report.rb index d8beb23e60..c3c0c8980a 100644 --- a/lib/report.rb +++ b/lib/report.rb @@ -150,7 +150,7 @@ class Report < ActiveRecord::Base def cache_key deserialize unless @chain parts = [self.class.table_name.sub('_reports', '')] - parts.concat [filters, group_bys].map { |l| l.map(&:cache_key).sort.join(" ") } + parts.concat [filters.sort, group_bys].map { |l| l.map(&:cache_key).join(" ") } parts.join '/' end diff --git a/lib/report/filter/base.rb b/lib/report/filter/base.rb index f927a111ad..f57d840230 100644 --- a/lib/report/filter/base.rb +++ b/lib/report/filter/base.rb @@ -26,7 +26,7 @@ class Report::Filter end def cache_key - self.class.cache_key + operator.to_s + values.join(',') + self.class.cache_key + operator.to_s + Array(values).join(',') end ## @@ -60,6 +60,12 @@ class Report::Filter alias :dependents :dependent end + + # need this for sort + def <=> other + self.class.underscore_name <=> other.class.underscore_name + end + def self.has_dependent? !dependents.empty? end