Skip to content

Commit

Permalink
Fix premature exit during multiple show import
Browse files Browse the repository at this point in the history
  • Loading branch information
jcraigk committed Oct 19, 2023
1 parent 4278ace commit 989a33a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Join the [Discord](https://discord.gg/KZWFsNN) to discuss content and developmen

2. Clone the repo to your local machine

4. Download the [Fixtures Pack](https://www.dropbox.com/scl/fi/v8f2mpyxasx07tqvcqekl/PhishinDevFixtures.zip?rlkey=kav09ng2o08rcu11fs3sb38dv&dl=0) and unzip it. This file contains a full database export minus users and API keys. It also includes MP3 audio and PNG waveform attachments for the last Baker's Dozen show, which should be browsable and playable via `localhost:3000/2017-08-06` once the local server is running. Additionally it includes MP3s/notes for 2018-12-28 for testing the `rails shows:import` task.
4. Download the [Fixtures Pack](https://www.dropbox.com/scl/fi/s822to1wv8y7ra3l3pao1/PhishinDevFixtures.zip?rlkey=t1us9qzosl941hak2msujcfuy&dl=0) and unzip it. This file contains a full database export minus users and API keys. It also includes MP3 audio and PNG waveform attachments for the last Baker's Dozen show, which should be browsable and playable via `localhost:3000/2017-08-06` once the local server is running. Additionally it includes MP3s/notes for 2018-12-28 for testing the `rails shows:import` task.

```bash
# Copy the SQL dump into PG container and run it
docker cp /path/to/phishin_for_devs.sql phishin_pg_1:/docker-entrypoint-initdb.d/dump.sql
docker exec -u postgres phishin_pg_1 psql phishin postgres -f docker-entrypoint-initdb.d/dump.sql
```

5. Create a folder named `content` in your local `phishin` folder to store mp3s, pngs, etc. Place the `tracks` and `import` folders from the Fixtures Pack inside the `content` folder. Symlink it to your public folder: `ln -s ./content/tracks/audio_files public/audio`. If you run Rails outside Docker, set its location as `APP_CONTENT_PATH` in `.env`.
5. Create a folder named `content` in the local project folder. Place the `tracks` and `import` folders from the Fixtures Pack inside. Symlink the `tracks/audio_files` folder as `audio` in your public folder: `ln -s ./content/tracks/audio_files public/audio`. If you run Rails outside Docker, set `APP_CONTENT_PATH` in `.env` as the absolute path to your `content` folder.

6. If you want to run the Postgres database in Docker and develop the app natively (recommended), you can spin it up like this:

Expand Down
7 changes: 4 additions & 3 deletions app/services/show_importer/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ class ShowImporter::Cli
attr_reader :orch

def initialize(date)
puts "Preparing #{date}"

@orch = ShowImporter::Orchestrator.new(date)
ShowImporter::TrackReplacer.new(date) && return if orch.show_found

repl
end

Expand Down Expand Up @@ -147,6 +150,7 @@ def repl
main_menu
while (line = Readline.readline('↪ ', true))
process(line)
break if line.in?(%w[s x])
end
end

Expand All @@ -170,9 +174,6 @@ def menu_branch(line) # rubocop:disable Metrics/MethodLength
main_menu
when 's'
orch.save
exit
when 'x'
exit
end
end
end
2 changes: 1 addition & 1 deletion app/services/show_importer/orchestrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def save_track(track)
end

def success
puts "✅ #{show.date} imported"
puts "✅ #{show.date} imported\n\n"
end

def populate_tracks
Expand Down
4 changes: 2 additions & 2 deletions app/services/show_importer/track_replacer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def replace_audio_on_tracks

def ensure_tracks_present
return unless nil_tracks.any?
abort "❌ Not all files matched: #{nil_tracks.keys}"
abort "❌ #{@show.date} => Not all files matched: #{nil_tracks.keys}"
end

def nil_tracks
Expand All @@ -59,7 +59,7 @@ def nil_tracks

def ensure_all_tracks_matched
return if unmatched_tracks.empty?
abort "❌ Not all tracks matched: #{unmatched_tracks}"
abort "❌ #{@show.date} => Not all tracks matched: #{unmatched_tracks}"
end

def unmatched_tracks
Expand Down

0 comments on commit 989a33a

Please sign in to comment.