Sha256: 5e37ab878ab0461430253c17a1e6b530dff7b03c08c56bd3da171b2e0f1e64ec
Contents?: true
Size: 779 Bytes
Versions: 18
Compression:
Stored size: 779 Bytes
Contents
module Partitioned # # Partition tables by a time field grouping them by year. # class ByYearlyTimeField < ByTimeField self.abstract_class = true # Normalize a partition key value by year. # # @param [Time] time_value the time value to normalize # @return [Time] the value normalized def self.partition_normalize_key_value(time_value) return time_value.at_beginning_of_year end # The size of the partition table, a year # # @return [Integer] the size of this partition def self.partition_table_size return 1.year end partitioned do |partition| partition.base_name lambda { |model, time_field| return model.partition_normalize_key_value(time_field).strftime('%Y') } end end end
Version data entries
18 entries across 18 versions & 1 rubygems