Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
4 lib/active_olap.rb
@@ -3,6 +3,8 @@ module ActiveOLAP
def enable_active_olap(config = nil, &block)
self.send(:extend, ClassMethods)
+ self.send(:extend, Utils)
+
self.named_scope :olap_drilldown, lambda { |hash| self.olap_drilldown_finder_options(hash) }
self.cattr_accessor :active_olap_dimensions, :active_olap_aggregates
@@ -100,7 +102,7 @@ def olap_temporarily_reset_join_type
end
-
+require "active_olap/utils"
require 'active_olap/dimension'
require 'active_olap/category'
require 'active_olap/aggregate'
View
3  lib/active_olap/configurator.rb
@@ -11,6 +11,9 @@ def initialize(klass)
# registers a dimension for the class it belongs to
def dimension(name, definition = nil)
+ if definition.is_a?(Hash)
+ definition[:name] = name
+ end
definition = name.to_sym if definition.nil?
@klass.active_olap_dimensions[name] = definition
end
View
15 lib/active_olap/dimension.rb
@@ -1,7 +1,10 @@
module ActiveOLAP
class Dimension
-
+
+ #include ActiveOLAP::NamedTimedDimensionHelper
+ include ActiveOLAP::Utils
+
attr_reader :klass
attr_reader :categories
attr_reader :category_field
@@ -10,6 +13,8 @@ class Dimension
attr_reader :joins
attr_reader :conditions
+ attr_accessor :name
+
# creates a new Dimension, given a definition.
# The definition can be:
# - A name (Symbol) of registered definition
@@ -175,10 +180,11 @@ def initialize(klass, definition)
# make the remaining fields available in the info object
@info.merge!(hash)
+ self.name = definition[:name].to_s
when Symbol
generate_field_dimension(definition)
-
+ self.name = definition.to_s
else
raise "Invalid category definition! " + definition.inspect
end
@@ -198,7 +204,7 @@ def generate_field_dimension(field)
end
def generate_custom_categories(categories)
- skip_other = false
+ skip_other = true
categories.to_a.each do |category|
skip_other = true if category.first == :other
register_category(category.first, category.last) if category.last
@@ -207,6 +213,7 @@ def generate_custom_categories(categories)
end
def generate_trend_categories(trend_definition)
+ trend_definition = trend_definition.dup
period_count = trend_definition.delete(:periods) || trend_definition.delete(:period_count) || 14
period_length = trend_definition.delete(:period_length) || 1.days
trend_end = trend_definition.delete(:end) || Time.now.utc.midnight + 1.day
@@ -231,4 +238,4 @@ def generate_trend_categories(trend_definition)
@info[:trend] = true
end
end
-end
+end
View
17 lib/active_olap/utils.rb
@@ -0,0 +1,17 @@
+module ActiveOLAP
+ module Utils
+ # Merges conditions so that the result is a valid +condition+
+ def merge_conditions(*conditions)
+ segments = []
+
+ conditions.each do |condition|
+ unless condition.blank?
+ sql = self.send(:sanitize_sql, condition)
+ segments << sql unless sql.blank?
+ end
+ end
+
+ "(#{segments.join(') AND (')})" unless segments.empty?
+ end
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.