Class: Cubicle::Query
- Inherits:
-
Object
- Object
- Cubicle::Query
- Includes:
- Dsl
- Defined in:
- lib/cubicle/query.rb,
lib/cubicle/query/dsl.rb,
lib/cubicle/query/dsl/time_intelligence.rb
Defined Under Namespace
Modules: Dsl
Instance Attribute Summary collapse
-
#aggregation ⇒ Object
readonly
Returns the value of attribute aggregation.
-
#named_expressions ⇒ Object
readonly
Returns the value of attribute named_expressions.
-
#query_aliases ⇒ Object
readonly
Returns the value of attribute query_aliases.
-
#source_collection_name ⇒ Object
Returns the value of attribute source_collection_name.
-
#time_period ⇒ Object
readonly
Returns the value of attribute time_period.
-
#transient ⇒ Object
readonly
Returns the value of attribute transient.
Instance Method Summary collapse
- #all_dimensions? ⇒ Boolean
- #all_measures? ⇒ Boolean
- #clone ⇒ Object
- #dimension_names ⇒ Object
- #dimensions ⇒ Object
- #execute(options = {}) ⇒ Object
-
#initialize(aggregation) ⇒ Query
constructor
A new instance of Query.
- #measures ⇒ Object
- #member_names ⇒ Object
- #selected?(member = nil) ⇒ Boolean
- #transient? ⇒ Boolean
Methods included from Dsl
#alias_member, #by, #define, #limit, #offset, #order_by, #select, #select_all, #transient!, #where
Methods included from Dsl::TimeIntelligence
#from, #last, #last_complete, #mtd, #next, #this, #time_dimension, #time_range, #until, #ytd
Constructor Details
#initialize(aggregation) ⇒ Query
Returns a new instance of Query.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cubicle/query.rb', line 8 def initialize(aggregation) @aggregation = aggregation @dimensions = Cubicle::MemberList.new @measures = Cubicle::MemberList.new @source_collection_name = @aggregation.target_collection_name @where, @from_date, @to_date, @date_dimension, @time_period, @limit, @offset = nil @all_dimensions, @all_measures = false, false @transient = false @by=[] @order_by=[] @from_date_filter = "$gte" @to_date_filter = "$lte" @query_aliases=HashWithIndifferentAccess.new @named_expressions=HashWithIndifferentAccess.new end |
Instance Attribute Details
#aggregation ⇒ Object (readonly)
Returns the value of attribute aggregation.
5 6 7 |
# File 'lib/cubicle/query.rb', line 5 def aggregation @aggregation end |
#named_expressions ⇒ Object (readonly)
Returns the value of attribute named_expressions.
5 6 7 |
# File 'lib/cubicle/query.rb', line 5 def named_expressions @named_expressions end |
#query_aliases ⇒ Object (readonly)
Returns the value of attribute query_aliases.
5 6 7 |
# File 'lib/cubicle/query.rb', line 5 def query_aliases @query_aliases end |
#source_collection_name ⇒ Object
Returns the value of attribute source_collection_name.
6 7 8 |
# File 'lib/cubicle/query.rb', line 6 def source_collection_name @source_collection_name end |
#time_period ⇒ Object (readonly)
Returns the value of attribute time_period.
5 6 7 |
# File 'lib/cubicle/query.rb', line 5 def time_period @time_period end |
#transient ⇒ Object (readonly)
Returns the value of attribute transient.
5 6 7 |
# File 'lib/cubicle/query.rb', line 5 def transient @transient end |
Instance Method Details
#all_dimensions? ⇒ Boolean
45 46 47 |
# File 'lib/cubicle/query.rb', line 45 def all_dimensions? @all_dimensions end |
#all_measures? ⇒ Boolean
41 42 43 |
# File 'lib/cubicle/query.rb', line 41 def all_measures? @all_measures end |
#clone ⇒ Object
25 26 27 |
# File 'lib/cubicle/query.rb', line 25 def clone Marshal.load(Marshal.dump(self)) end |
#dimension_names ⇒ Object
49 50 51 |
# File 'lib/cubicle/query.rb', line 49 def dimension_names return dimensions.map{|dim|dim.name.to_s} end |
#dimensions ⇒ Object
57 58 59 60 |
# File 'lib/cubicle/query.rb', line 57 def dimensions return @dimensions unless all_dimensions? @aggregation.dimensions.collect{|dim|convert_dimension(dim)} end |
#execute(options = {}) ⇒ Object
67 68 69 |
# File 'lib/cubicle/query.rb', line 67 def execute(={}) @aggregation.execute_query(self,) end |
#measures ⇒ Object
62 63 64 65 |
# File 'lib/cubicle/query.rb', line 62 def measures return @measures unless all_measures? @aggregation.measures.collect{|measure|convert_measure(measure)} end |
#member_names ⇒ Object
53 54 55 |
# File 'lib/cubicle/query.rb', line 53 def member_names return (dimensions + measures).map{|m|m.name.to_s} end |
#selected?(member = nil) ⇒ Boolean
29 30 31 32 33 34 |
# File 'lib/cubicle/query.rb', line 29 def selected?(member = nil) return (@dimensions.length > 0 || @measures.length > 0) unless member member_name = member.kind_of?(Cubicle::Member) ? member.name : unalias(member.to_s) return @dimensions[member_name] || @measures[member_name] end |
#transient? ⇒ Boolean
36 37 38 |
# File 'lib/cubicle/query.rb', line 36 def transient? @transient || @aggregation.transient? end |