using Managing.Domain.Synth.Models;

namespace Managing.Application.Abstractions.Repositories;

/// <summary>
/// Repository interface for Synth-related data operations
/// Provides MongoDB persistence for leaderboard and individual predictions data
/// </summary>
public interface ISynthRepository
{
    /// <summary>
    /// Gets cached leaderboard data by cache key
    /// </summary>
    /// <param name="cacheKey">The cache key to search for</param>
    /// <returns>Cached leaderboard data if found, null otherwise</returns>
    Task<SynthMinersLeaderboard?> GetLeaderboardAsync(string cacheKey);
    
    /// <summary>
    /// Saves leaderboard data to MongoDB
    /// </summary>
    /// <param name="leaderboard">The leaderboard data to save</param>
    Task SaveLeaderboardAsync(SynthMinersLeaderboard leaderboard);

    /// <summary>
    /// Gets individual cached prediction data by asset, parameters, and miner UIDs
    /// </summary>
    /// <param name="asset">Asset symbol</param>
    /// <param name="timeIncrement">Time increment in seconds</param>
    /// <param name="timeLength">Time length in seconds</param>
    /// <param name="minerUids">List of miner UIDs to get predictions for</param>
    /// <param name="isBacktest">Whether this is backtest data</param>
    /// <param name="signalDate">Signal date for backtest data</param>
    /// <returns>List of cached individual predictions</returns>
    Task<List<SynthPrediction>> GetIndividualPredictionsAsync(
        string asset, 
        int timeIncrement, 
        int timeLength, 
        List<int> minerUids, 
        bool isBacktest, 
        DateTime? signalDate);

    /// <summary>
    /// Saves individual prediction data to MongoDB
    /// </summary>
    /// <param name="prediction">The individual prediction data to save</param>
    Task SaveIndividualPredictionAsync(SynthPrediction prediction);

    /// <summary>
    /// Saves multiple individual predictions to MongoDB in batch
    /// </summary>
    /// <param name="predictions">The list of individual predictions to save</param>
    Task SaveIndividualPredictionsAsync(List<SynthPrediction> predictions);
    
    /// <summary>
    /// Cleans up old cached data beyond the retention period
    /// </summary>
    /// <param name="retentionDays">Number of days to retain data</param>
    Task CleanupOldDataAsync(int retentionDays = 30);
} 