 defmodule ExMoney.Saltedge.TransactionsScheduler do
   use GenServer
   require Logger
-
-  alias ExMoney.Account
-  alias ExMoney.Repo
 
   @interval 60 * 1000
 

    case current_hour() do
      hour when hour >= 0 and hour < 7 ->
        # FIXME: handle genserver answer
        GenServer.call(:transactions_worker, :stop)
        # Start transactions worker in 7 hours
        Process.send_after(self(), :start_worker, 7 * 60 * 60 * 1000)


  end

  def handle_info(:start_worker, state) do
    result = Supervisor.restart_child(
      ExMoney.Supervisor,
      ExMoney.Saltedge.TransactionsWorker
    )
    Logger.info("Time to wake up, TransactionsWorker has been started with result => #{inspect(result)}")

    Process.send_after(self(), :schedule, @interval)

