Class: Gitlab::Database::Aggregation::ClickHouse::DateBucketDimension
- Inherits:
-
Column
- Object
- PartDefinition
- Column
- Gitlab::Database::Aggregation::ClickHouse::DateBucketDimension
- Includes:
- ParameterizedDefinition
- Defined in:
- lib/gitlab/database/aggregation/click_house/date_bucket_dimension.rb
Constant Summary collapse
- GRANULARITIES_MAP =
{ daily: :day, weekly: :week, monthly: :month, yearly: :year }.with_indifferent_access.freeze
- DEFAULT_GRANULARITY =
:monthly
Instance Attribute Summary
Attributes included from ParameterizedDefinition
Attributes inherited from Column
#expression, #name, #secondary_expression, #type
Attributes inherited from PartDefinition
#description, #expression, #formatter, #name, #secondary_expression, #type
Instance Method Summary collapse
Methods included from ParameterizedDefinition
Methods inherited from Column
#initialize, #secondary_arel, #to_inner_arel
Methods inherited from PartDefinition
#format_value, #identifier, #initialize, #instance_key, #parameterized?
Instance Method Details
#to_outer_arel(context) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/gitlab/database/aggregation/click_house/date_bucket_dimension.rb', line 26 def to_outer_arel(context) granularity = instance_parameter(:granularity, context[name]) || DEFAULT_GRANULARITY granularity = GRANULARITIES_MAP[granularity] context[:scope].func('toStartOfInterval', [super, Arel.sql("INTERVAL 1 #{granularity}")]) end |
#validate_part(part) ⇒ Object
21 22 23 24 |
# File 'lib/gitlab/database/aggregation/click_house/date_bucket_dimension.rb', line 21 def validate_part(part) super validate_granularity(part) end |