package nextgenrepoter

import (
	"context"
	"time"

	"github.com/tidbcloud/metering/pkg/common/models"
)

// NextGenRepoterLoader responsible for reading data from DeltaLake and managing checkpoints
type NextGenRepoterLoader interface {
	// LoadMeteringDataInTimeRange reads metering data within the specified time range from DeltaLake
	LoadMeteringDataInTimeRange(ctx context.Context, startTime, endTime int64) ([]*models.BillingReportV2Deltalake, error)

	// LoadCheckpoint loads checkpoint
	LoadCheckpoint(ctx context.Context) (int64, error)

	// SaveCheckpoint saves checkpoint
	SaveCheckpoint(ctx context.Context, checkpoint int64) error

	LoadMeteringDataInTimeRangeWithDeltaRS(ctx context.Context, startTime, endTime int64) ([]*models.BillingReportV2Deltalake, error)
}

// NextGenRepoter NextGen version metering reporter interface
type NextGenRepoter interface {
	// Report executes reporting task, sends data to billing SQS
	Report(ctx context.Context) error
}

// HourlyBatch represents data batch grouped by hour
type HourlyBatch struct {
	Hour      time.Time                          // Hour timestamp
	StartTime int64                              // Start timestamp of this hour
	EndTime   int64                              // End timestamp of this hour
	Reports   []*models.BillingReportV2Deltalake // Report data within this hour
}
