package parquet

import (
	"fmt"
	"time"

	"github.com/tidbcloud/observability/cmd/diagnosis-compute/pkg/config"
	"github.com/tidbcloud/observability/cmd/diagnosis-compute/pkg/types"
)

func S3ObjectKey(info types.ClusterInfo, hourBegin int64, component string, seq int) string {
	t := time.Unix(hourBegin, 0).UTC()
	date := t.Format("2006-01-02")
	hour := t.Format("15")
	// component is only a path partition (component=...); do not repeat it in the object name.
	filename := fmt.Sprintf("%s_%s_%02d.parquet", hour, info.ClusterID, seq)
	return fmt.Sprintf(
		"deltalake/global/logs/env=%s/deployType=%s/date=%s/component=%s/%s",
		info.Env,
		config.DeployType(info),
		date,
		component,
		filename,
	)
}
