package backups_config

import (
	"github.com/google/uuid"

	"databasus-backend/internal/features/intervals"
	"databasus-backend/internal/features/storages"
	"databasus-backend/internal/util/period"
)

func EnableBackupsForTestDatabase(
	databaseID uuid.UUID,
	storage *storages.Storage,
) *BackupConfig {
	timeOfDay := "16:00"

	backupConfig := &BackupConfig{
		DatabaseID:          databaseID,
		IsBackupsEnabled:    true,
		RetentionPolicyType: RetentionPolicyTypeTimePeriod,
		RetentionTimePeriod: period.PeriodDay,
		BackupInterval: &intervals.Interval{
			Interval:  intervals.IntervalDaily,
			TimeOfDay: &timeOfDay,
		},
		StorageID: &storage.ID,
		Storage:   storage,
		SendNotificationsOn: []BackupNotificationType{
			NotificationBackupFailed,
			NotificationBackupSuccess,
		},
	}

	backupConfig, err := GetBackupConfigService().SaveBackupConfig(backupConfig)
	if err != nil {
		panic(err)
	}

	return backupConfig
}
