Skip to content

Commit 18eb866

Browse files
authored
Merge pull request #13 from ndrean/main
Refactor
2 parents 0c5d2d8 + f8932c8 commit 18eb866

File tree

5 files changed

+14
-34
lines changed

5 files changed

+14
-34
lines changed

config/runtime.exs

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ if config_env() == :prod do
4040
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "5"),
4141
show_sensitive_data_on_connection_error: true
4242

43+
config :solidyjs, SqliteHandler,
44+
database_path: database_path
45+
4346
secret_key_base =
4447
System.get_env("SECRET_KEY_BASE") ||
4548
raise """

fly.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ kill_signal = 'SIGTERM'
1010
[build]
1111

1212
[env]
13-
DATABASE_PATH = '/db/db/airports.db'
13+
DATABASE_PATH = '/app/db/airports.db'
1414
PHX_HOST = 'solidyjs-lively-pine-4375.fly.dev'
1515
PORT = '8080'
1616
MIX_ENV = 'prod'
1717

1818
[[mounts]]
19-
source = 'db'
19+
source = 'app'
2020
destination = '/db'
2121
auto_extend_size_threshold = 80
2222
auto_extend_size_increment = '1GB'

lib/solidyjs/application.ex

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ defmodule Solidyjs.Application do
88
@impl true
99
def start(_type, _args) do
1010
start_ets_tables()
11-
# Solidyjs.Release.migrate()
11+
Solidyjs.Release.migrate()
1212

1313
children = [
1414
SolidyjsWeb.Telemetry,
1515
{DNSCluster, query: Application.get_env(:solidyjs, :dns_cluster_query) || :ignore},
1616
{Phoenix.PubSub, name: :pubsub},
1717
SolidyjsWeb.Endpoint,
1818
Solidyjs.Repo,
19-
{SqliteHandler, [Application.fetch_env!(:solidyjs, Solidyjs.Repo)[:database], "airports"]}
19+
{SqliteHandler, [
20+
Application.get_env(:solidyjs, :sqlite_handler)[:database_path],
21+
"airports"
22+
]}
2023
]
2124

2225
# See https://hexdocs.pm/elixir/Supervisor.html

lib/solidyjs/sqlite_handler.ex

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ defmodule SqliteHandler do
7575
Airports.download()
7676
end
7777

78+
db_name = Path.join(Application.app_dir(:solidyjs), System.fetch_env!("DATABASE_PATH"))
79+
Logger.info(inspect(db_name))
80+
7881
# Check if we have data in the table
79-
case Sqlite3.prepare(conn, "SELECT COUNT(*) FROM #{name}") do
82+
case Sqlite3.prepare(conn, "SELECT COUNT(*) FROM #{db_name}") do
8083
{:ok, stmt} ->
8184
run_step(state, stmt)
8285

my-fly.toml

-29
This file was deleted.

0 commit comments

Comments
 (0)