Skip to content

Commit

Permalink
refactor: revert configs to toml
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowHatpro committed Sep 1, 2024
1 parent 77caac5 commit 4f3d2f7
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 78 deletions.
14 changes: 14 additions & 0 deletions config/default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[retry_task]
retry_interval = 86400 # 60*60*24 seconds
select_limit = 10
allow_remove_row_after = 86400

[poller_task]
poll_interval = 10

[notify_task]
notify_interval = 10

[listen_task]
listen_interval = 5
sleep_status_interval = 120
14 changes: 0 additions & 14 deletions config/default.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
debug = true

[wayback_machine_api]
myaccesskey = "OqvSkX8Sv5hblwrv"
mysecret = "tjow7aOFJAWokDsX"

[retry_task]
retry_interval = 120 # 2 min
allow_remove_row_after = 600 # 10 min

[sentry]
url = "enter sentry DSN here"

[database]
pg_host = "localhost" # If running as a docker container, change this to musicbrainz-docker-db-1
pg_port = "5432"
pg_user = "musicbrainz"
pg_password = "musicbrainz"
pg_database = "musicbrainz_db"
database_url = "postgres://musicbrainz:musicbrainz@localhost:5432/musicbrainz_db"
20 changes: 0 additions & 20 deletions config/development.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions config/production.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
debug = false

[wayback_machine_api]
myaccesskey = "wayback-machine-access-key"
mysecret = "wayback-machine-secret"

[sentry]
url = "enter your project url"

[database]
pg_host = ""
pg_port = ""
pg_user = ""
pg_password = ""
pg_database = ""
database_url = ""
16 changes: 0 additions & 16 deletions config/production.yaml

This file was deleted.

19 changes: 9 additions & 10 deletions scripts/generate_fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ if ! command -v yq &> /dev/null; then
exit 1
fi

CONFIG_FILE="../config/development.toml"

CONFIG_FILE="../config/development.yaml"

PG_HOST=$(yq -r '.database.pg_host' "$CONFIG_FILE")
PG_PORT=$(yq -r '.database.pg_port' "$CONFIG_FILE")
PG_USER=$(yq -r '.database.pg_user' "$CONFIG_FILE")
PG_PASSWORD=$(yq -r '.database.pg_password' "$CONFIG_FILE")
PG_DATABASE=$(yq -r '.database.pg_database' "$CONFIG_FILE")
DATABASE_URL=$(yq -r '.database.database_url' "$CONFIG_FILE")
PG_HOST=$(yq -p toml -r '.database.pg_host' "$CONFIG_FILE")
PG_PORT=$(yq -p toml -r '.database.pg_port' "$CONFIG_FILE")
PG_USER=$(yq -p toml -r '.database.pg_user' "$CONFIG_FILE")
PG_PASSWORD=$(yq -p toml -r '.database.pg_password' "$CONFIG_FILE")
PG_DATABASE=$(yq -p toml -r '.database.pg_database' "$CONFIG_FILE")
DATABASE_URL=$(yq -p toml -r '.database.database_url' "$CONFIG_FILE")

export PGHOST=$PG_HOST
export PGPORT=$PG_PORT
Expand All @@ -25,15 +24,15 @@ export PGDATABASE=$PG_DATABASE
# Get the project root directory using cargo
project_root=$(cargo locate-project --workspace --message-format plain | xargs dirname)

dump_dir="$project_root/tests1/fixtures"
dump_dir="$project_root/tests/fixtures"
mkdir -p "$dump_dir"

tables=("external_url_archiver.internet_archive_urls" "external_url_archiver.last_unprocessed_rows" "musicbrainz.edit_data" "musicbrainz.edit_note" "musicbrainz.edit" "musicbrainz.editor")

# Array to keep track of created backup tables
backup_tables=()

# Function to create, verify, dump a new table
# Function to create, verify, and dump a new table
dump_table() {
local table="$1"
local schema_name
Expand Down
17 changes: 8 additions & 9 deletions scripts/init_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ if ! command -v yq &> /dev/null; then
exit 1
fi


CONFIG_FILE="../config/development.yaml"

PG_HOST=$(yq -r '.database.pg_host' "$CONFIG_FILE")
PG_PORT=$(yq -r '.database.pg_port' "$CONFIG_FILE")
PG_USER=$(yq -r '.database.pg_user' "$CONFIG_FILE")
PG_PASSWORD=$(yq -r '.database.pg_password' "$CONFIG_FILE")
PG_DATABASE=$(yq -r '.database.pg_database' "$CONFIG_FILE")
DATABASE_URL=$(yq -r '.database.database_url' "$CONFIG_FILE")
CONFIG_FILE="../config/development.toml"

PG_HOST=$(yq -p toml -r '.database.pg_host' "$CONFIG_FILE")
PG_PORT=$(yq -p toml -r '.database.pg_port' "$CONFIG_FILE")
PG_USER=$(yq -p toml -r '.database.pg_user' "$CONFIG_FILE")
PG_PASSWORD=$(yq -p toml -r '.database.pg_password' "$CONFIG_FILE")
PG_DATABASE=$(yq -p toml -r '.database.pg_database' "$CONFIG_FILE")
DATABASE_URL=$(yq -p toml -r '.database.database_url' "$CONFIG_FILE")

export PGHOST=$PG_HOST
export PGPORT=$PG_PORT
Expand Down
17 changes: 8 additions & 9 deletions scripts/reinit_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ if ! command -v yq &> /dev/null; then
exit 1
fi


CONFIG_FILE="../config/development.yaml"

PG_HOST=$(yq -r '.database.pg_host' "$CONFIG_FILE")
PG_PORT=$(yq -r '.database.pg_port' "$CONFIG_FILE")
PG_USER=$(yq -r '.database.pg_user' "$CONFIG_FILE")
PG_PASSWORD=$(yq -r '.database.pg_password' "$CONFIG_FILE")
PG_DATABASE=$(yq -r '.database.pg_database' "$CONFIG_FILE")
DATABASE_URL=$(yq -r '.database.database_url' "$CONFIG_FILE")
CONFIG_FILE="../config/development.toml"

PG_HOST=$(yq -p toml -r '.database.pg_host' "$CONFIG_FILE")
PG_PORT=$(yq -p toml -r '.database.pg_port' "$CONFIG_FILE")
PG_USER=$(yq -p toml -r '.database.pg_user' "$CONFIG_FILE")
PG_PASSWORD=$(yq -p toml -r '.database.pg_password' "$CONFIG_FILE")
PG_DATABASE=$(yq -p toml -r '.database.pg_database' "$CONFIG_FILE")
DATABASE_URL=$(yq -p toml -r '.database.database_url' "$CONFIG_FILE")

export PGHOST=$PG_HOST
export PGPORT=$PG_PORT
Expand Down

0 comments on commit 4f3d2f7

Please sign in to comment.