@@ -13,16 +13,15 @@ class Aggregator:
1313 blocks they produced
1414 """
1515
16- def __init__ (self , project , io_dir , data_to_aggregate ):
16+ def __init__ (self , project , io_dir ):
1717 """
1818 :param project: str. Name of the project
1919 :param io_dir: Path. Path to the project's output directory
20- :param data_to_aggregate: list of dictionaries, sorted by 'timestamp'; the data that will be aggregated
2120 """
2221 self .project = project
23- self .data_to_aggregate = data_to_aggregate
24- self .data_start_date = hlp .get_timeframe_beginning (hlp .get_date_from_block (data_to_aggregate [0 ]))
25- self .data_end_date = hlp .get_timeframe_beginning (hlp .get_date_from_block (data_to_aggregate [- 1 ]))
22+ self .data_to_aggregate = hlp . read_mapped_project_data ( io_dir )
23+ self .data_start_date = hlp .get_timeframe_beginning (hlp .get_date_from_block (self . data_to_aggregate [0 ]))
24+ self .data_end_date = hlp .get_timeframe_beginning (hlp .get_date_from_block (self . data_to_aggregate [- 1 ]))
2625 self .aggregated_data_dir = io_dir / 'blocks_per_entity'
2726 self .aggregated_data_dir .mkdir (parents = True , exist_ok = True )
2827
@@ -91,7 +90,7 @@ def divide_timeframe(timeframe, granularity):
9190 return list (zip (start_dates , end_dates ))
9291
9392
94- def aggregate (project , output_dir , timeframe , aggregate_by , force_aggregate , mapped_data = None ):
93+ def aggregate (project , output_dir , timeframe , aggregate_by , force_aggregate ):
9594 """
9695 Aggregates the results of the mapping process for the given project and timeframe. The results are saved in a csv
9796 file in the project's output directory. Note that the output file is created (just with the headers) even if there
@@ -103,15 +102,11 @@ def aggregate(project, output_dir, timeframe, aggregate_by, force_aggregate, map
103102 year, all
104103 :param force_aggregate: bool. If True, then the aggregation will be performed, regardless of whether aggregated
105104 data for the project and specified granularity already exist
106- :param mapped_data: list of dictionaries (the data that will be aggregated). If None, then the data will be read
107- from the project's output directory
108105 :returns: a list of strings that correspond to the time chunks of the aggregation or None if no aggregation took
109106 place (the corresponding output file already existed and force_aggregate was set to False)
110107 """
111108 project_io_dir = output_dir / project
112- if mapped_data is None :
113- mapped_data = hlp .read_mapped_project_data (project_io_dir )
114- aggregator = Aggregator (project , project_io_dir , mapped_data )
109+ aggregator = Aggregator (project , project_io_dir )
115110
116111 filename = hlp .get_blocks_per_entity_filename (aggregate_by = aggregate_by , timeframe = timeframe )
117112 output_file = aggregator .aggregated_data_dir / filename
0 commit comments