# This file is responsible for configuring your application
# and its dependencies with the aid of the Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.

# General application configuration
import Config

config :error_tracker,
  repo: MusicLibrary.Repo,
  otp_app: :music_library,
  enabled: false,
  ignorer: MusicLibrary.ErrorIgnorer

config :elixir, :time_zone_database, TimeZoneInfo.TimeZoneDatabase

config :time_zone_info, update: :daily

config :music_library,
  ecto_repos: [MusicLibrary.BackgroundRepo, MusicLibrary.Repo, MusicLibrary.TelemetryRepo],
  generators: [timestamp_type: :utc_datetime, binary_id: true]

config :music_library, default_timezone: "Europe/London"

config :music_library, :similarity, max_distance: 0.45

config :music_library, :excluded_genres, ["rock"]

config :music_library, :pagination,
  default_page_size: 20,
  stats_limit: 30,
  top_items_limit: 10,
  tracks_page_size: 200,
  search_preview_limit: 5

config :music_library, MusicLibraryWeb,
  login_password: "change me",
  api_token: "change me"

# Configures the endpoint
config :music_library, MusicLibraryWeb.Endpoint,
  url: [host: "localhost"],
  adapter: Bandit.PhoenixAdapter,
  render_errors: [
    formats: [html: MusicLibraryWeb.ErrorHTML, json: MusicLibraryWeb.ErrorJSON],
    layout: false
  ],
  pubsub_server: MusicLibrary.PubSub,
  live_view: [signing_salt: "g/qw4SNo"]

user_agent = "MusicLibrary/0.1.0 ( cloud8421@gmail.com )"

config :music_library, LastFm,
  user: "username",
  api_key: "change me",
  shared_secret: "change me",
  user_agent: user_agent,
  api_cooldown: 500

config :music_library, MusicBrainz, user_agent: user_agent, api_cooldown: 500

config :music_library, Discogs,
  personal_access_token: "change me",
  user_agent: user_agent,
  api_cooldown: 1000

config :music_library, Wikipedia, user_agent: user_agent, api_cooldown: 1000

config :music_library, BraveSearch,
  api_key: "change me",
  user_agent: user_agent,
  api_cooldown: 1000

config :music_library, OpenAI, api_key: "change me"

# Configure esbuild (the version is required)
config :esbuild,
  version: "0.27.4",
  music_library: [
    args:
      ~w(js/app.js --bundle --target=es2022 --outdir=../priv/static/assets --external:/fonts/* --external:/images/* --alias:@=.),
    cd: Path.expand("../assets", __DIR__),
    env: %{"NODE_PATH" => [Path.expand("../deps", __DIR__), Mix.Project.build_path()]}
  ]

# Configure tailwind (the version is required)
config :tailwind,
  version: "4.2.2",
  music_library: [
    args: ~w(
      --input=assets/css/app.css
      --output=priv/static/assets/app.css
    ),
    cd: Path.expand("..", __DIR__)
  ]

# Configures Elixir's Logger
config :logger, :default_formatter,
  format: "$time $metadata[$level] $message\n",
  metadata: [:request_id]

# Use JSON for JSON parsing in Phoenix
config :phoenix, :json_library, JSON

config :music_library, Oban,
  engine: Oban.Engines.Lite,
  queues: [default: 10, heavy_writes: 1, music_brainz: 1, discogs: 1, wikipedia: 1, last_fm: 1],
  repo: MusicLibrary.BackgroundRepo

# Timing metrics (execution time, queue time) are stored in space-efficient
# quantile sketches. By default, values are recorded in `:native` time units
# (nanoseconds on most systems), which provides maximum precision but uses more
# space.
# For reduced storage size (~20% smaller) and better bin consolidation, we
# configure sketches to store timing in millisecond
config :oban_met, sketch_time_unit: :millisecond

config :music_library, MusicLibrary.BackgroundRepo, priv: "priv/background_repo"

config :music_library, MusicLibrary.TelemetryRepo, priv: "priv/telemetry_repo", log: false

config :music_library, MusicLibraryWeb.Telemetry.Storage, buffer_size: 32_768

config :swoosh, :api_client, Swoosh.ApiClient.Req

config :music_library, MusicLibrary.Mailer,
  adapter: Swoosh.Adapters.Mailgun,
  api_key: "change me",
  domain: "change me"

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

config :fluxon, :translate_function, &MusicLibraryWeb.CoreComponents.translate_error/1

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"
