package queries

import (
	"bssapp-backend/db"
	"context"
	"fmt"
)

// RebuildStatementAgingCache runs only step 2 + step 3.
func RebuildStatementAgingCache(ctx context.Context) error {
	if _, err := db.MssqlDB.ExecContext(ctx, `EXEC dbo.SP_BUILD_CARI_VADE_GUN_STAGING;`); err != nil {
		return fmt.Errorf("SP_BUILD_CARI_VADE_GUN_STAGING error: %w", err)
	}

	if _, err := db.MssqlDB.ExecContext(ctx, `EXEC dbo.SP_BUILD_CARI_BAKIYE_CACHE;`); err != nil {
		return fmt.Errorf("SP_BUILD_CARI_BAKIYE_CACHE error: %w", err)
	}

	return nil
}
