// worker/report_worker.go
package worker

import (
	"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
	"github.com/SamuelTariku/FortuneBet-Backend/internal/infrastructure"
	"github.com/SamuelTariku/FortuneBet-Backend/internal/services/report"
)

type ReportWorker struct {
	reportService *report.Service
	exporter      infrastructure.CSVExporter
}

func NewReportWorker(service *report.Service, exporter infrastructure.CSVExporter) *ReportWorker {
	return &ReportWorker{
		reportService: service,
		exporter:      exporter,
	}
}

func (w *ReportWorker) GenerateAndExport(timeFrame domain.TimeFrame) error {
	report, err := w.reportService.GenerateReport(timeFrame)
	if err != nil {
		return err
	}

	return w.exporter.Export(report)
}
