//+------------------------------------------------------------------+
//|                                    AggregationSummaryPrinter.mqh |
//|                     Prints a pipeline summary to the Experts tab |
//+------------------------------------------------------------------+
#ifndef AGGREGATIONSUMMARYPRINTER_MQH
#define AGGREGATIONSUMMARYPRINTER_MQH

#include "DailyAggregatorTypes.mqh"

//+------------------------------------------------------------------+
//| CAggregationSummaryPrinter                                       |
//| Stateless utility that prints a summary of one aggregation run.  |
//+------------------------------------------------------------------+
class CAggregationSummaryPrinter
  {
public:
   static void       PrintSummary(const int m1_bar_count,
                                   const CDailyBar &daily_bars[],
                                   const bool symbol_was_created,
                                   const string symbol_name);
  };

//+--------------------------------------------------------------------+
//| CAggregationSummaryPrinter::PrintSummary                           |
//| Assumptions: daily_bars is in ascending chronological order, which |
//|              CDailyAggregator::Aggregate() guarantees.             |
//| Returns: nothing; writes a short, human-readable summary to the    |
//|          Experts tab covering the M1 bar count, the number         |
//|          daily groups formed, the date range covered, and whether  |
//|          the custom symbol was newly created or already existed.   |
//+--------------------------------------------------------------------+
void CAggregationSummaryPrinter::PrintSummary(const int m1_bar_count,
                                               const CDailyBar &daily_bars[],
                                               const bool symbol_was_created,
                                               const string symbol_name)
  {
   int group_count=ArraySize(daily_bars);
//--- print the headline counts first
   Print("=== Daily OHLCV Aggregation Summary ===");
   Print("M1 bars read: ",m1_bar_count);
   Print("Session-aligned daily groups formed: ",group_count);
//--- report the date range covered, if any groups were formed
   if(group_count>0)
     {
      datetime earliest=daily_bars[0].GetOpenTime();
      datetime latest=daily_bars[group_count-1].GetOpenTime();
      Print("Date range covered: ",::TimeToString(earliest,TIME_DATE)," to ",::TimeToString(latest,TIME_DATE));
     }
   else
     {
      Print("Date range covered: none, no daily groups were produced");
     }
//--- report whether the destination custom symbol was newly created
   if(symbol_was_created)
      Print("Custom symbol '",symbol_name,"' was newly created and updated");
   else
      Print("Custom symbol '",symbol_name,"' already existed and was updated");
   Print("=== End of summary ===");
  }

#endif // AGGREGATIONSUMMARYPRINTER_MQH
//+--------------------------------------------------------------------+