using e_suite.Messaging.Common;
using e_suite.Scheduler.Scheduler;
using Microsoft.Extensions.Logging;

namespace e_suite.Scheduler.Jobs;

[Daily(hour:3)]
public class NightlyCleanUp : IJob
{
    private readonly IDatabaseMessageSender _databaseMessageSender;

    private readonly ILogger _logger;

    public NightlyCleanUp(IDatabaseMessageSender databaseMessageSender, ILogger logger)
    {
        _databaseMessageSender = databaseMessageSender;
        _logger = logger;
    }
    
    public Task ExecuteAsync()
    {
        _databaseMessageSender.PostClearOldEmailActions();
        _databaseMessageSender.PostClearOldPerformanceData();
        _databaseMessageSender.PostClearOldSentinelData();
        _logger.LogInformation("NightlyCleanUp messages sent");
        return Task.CompletedTask;
    }
}