import Config

# Note we also include the path to a cache manifest
# containing the digested version of static files. This
# manifest is generated by the `mix assets.deploy` task,
# which you should run after static files are built and
# before starting your production server.
config :music_library, MusicLibraryWeb.Endpoint,
  cache_static_manifest: "priv/static/cache_manifest.json"

# Do not print debug messages in production
config :logger, level: :info

config :music_library, monitoring_routes: true

config :error_tracker, enabled: true

config :music_library, ErrorTracker.ErrorNotifier,
  from_email: "postmaster@mailgun.fullyforged.com",
  to_email: "claudio@fullyforged.com",
  mailer: MusicLibrary.Mailer,
  base_url: "https://music-library.claudio-ortolina.org"

twelve_hours_in_seconds = 12 * 60 * 60

config :music_library, Oban,
  plugins: [
    {Oban.Plugins.Pruner, max_age: twelve_hours_in_seconds},
    {Oban.Plugins.Reindexer, schedule: "@weekly"},
    {Oban.Plugins.Cron,
     timezone: "Europe/London",
     crontab: [
       # every 12 hours
       {"0 */12 * * *", MusicLibrary.Worker.ApplyScrobbleRules},
       {"0 */12 * * *", MusicLibrary.Worker.PruneAssetCache},
       # every day at 2 am,
       {"0 2 * * *", MusicLibrary.Worker.PruneAssets},
       # every day at 3 am,
       {"0 3 * * *", MusicLibrary.Worker.RepoVacuum},
       # every day at 4 am,
       {"0 4 * * *", MusicLibrary.Worker.RepoOptimize},
       # every first day of the month, staggered hourly
       {"0 6 1 * *", MusicLibrary.Worker.RecordRefreshAllMusicBrainzData},
       {"0 7 1 * *", MusicLibrary.Worker.RecordGenerateAllEmbeddings},
       {"0 8 1 * *", MusicLibrary.Worker.ArtistRefreshAllMusicBrainzData},
       {"0 9 1 * *", MusicLibrary.Worker.ArtistRefreshAllDiscogsData},
       {"0 10 1 * *", MusicLibrary.Worker.ArtistRefreshAllWikipediaData},
       # daily at 7 am
       {"0 7 * * *", MusicLibrary.Worker.SendRecordsOnThisDayEmail},
       # every 5 minutes
       {"*/5 * * * *", MusicLibrary.Worker.RefreshScrobbles}
     ]}
  ]

# Runtime production configuration, including reading
# of environment variables, is done on config/runtime.exs.
