Class: RubyMaat::Groupers::TimeGrouper

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_maat/groupers/time_grouper.rb

Overview

Time grouper - aggregates commits within temporal periods

Instance Method Summary collapse

Constructor Details

#initialize(temporal_period) ⇒ TimeGrouper



7
8
9
# File 'lib/ruby_maat/groupers/time_grouper.rb', line 7

def initialize(temporal_period)
  @temporal_period = temporal_period
end

Instance Method Details

#group(change_records) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ruby_maat/groupers/time_grouper.rb', line 11

def group(change_records)
  # For now, implement daily aggregation (group commits by day)
  # The temporal_period parameter could be extended for other periods

  grouped_by_date_and_entity = {}

  change_records.each do |record|
    date = record.date
    entity = record.entity

    key = [date, entity]
    grouped_by_date_and_entity[key] ||= []
    grouped_by_date_and_entity[key] << record
  end

  # Create aggregated records for each group
  aggregated_records = []

  grouped_by_date_and_entity.each do |(date, entity), records|
    # Aggregate the records for this date/entity combination
    aggregated_record = aggregate_records(records, date, entity)
    aggregated_records << aggregated_record
  end

  aggregated_records
end