Skip to content

Commit

Permalink
Remove legacy tracks.waveform_image
Browse files Browse the repository at this point in the history
  • Loading branch information
jcraigk committed Oct 27, 2023
1 parent 47b578b commit 7d8078e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 32 deletions.
1 change: 0 additions & 1 deletion app/models/track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Track < ApplicationRecord
include AudioFileUploader::Attachment(:audio_file)
validates :audio_file, presence: true

include WaveformImageUploader::Attachment(:waveform_image)
include WaveformPngUploader::Attachment(:waveform_png)

include PgSearch::Model
Expand Down
5 changes: 0 additions & 5 deletions app/services/waveform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,6 @@ def rms(frames, channels = 1)

# Returns the peak voltage reached on the given channel in the given collection
# of frames.
#
# TODO: Could lose some resolution and only sample every other frame, would
# likely still generate the same waveform as the waveform is so comparitively
# low resolution to the original input (in most cases), and would increase
# the analyzation speed (maybe).
def channel_peak(frames, channel = 0)
peak = 0.0
frames.each do |frame|
Expand Down
2 changes: 1 addition & 1 deletion app/services/waveform_image_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def call
extract_waveform_data
generate_waveform_image
track.update!(
# waveform_max: data.max, # TODO: Re-enable or remove
waveform_max: data.max,
waveform_png: File.open(tmp_image)
)
remove_temp_files
Expand Down
5 changes: 0 additions & 5 deletions app/uploaders/waveform_image_uploader.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveWaveformImageFromTracks < ActiveRecord::Migration[7.1]
def change
remove_column :tracks, :waveform_image_data, :text
end
end
3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2023_10_19_231134) do
ActiveRecord::Schema[7.1].define(version: 2023_10_27_223005) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -200,7 +200,6 @@
t.integer "tags_count", default: 0
t.integer "jam_starts_at_second"
t.text "audio_file_data"
t.text "waveform_image_data"
t.float "waveform_max"
t.text "waveform_png_data"
t.index ["jam_starts_at_second"], name: "index_tracks_on_jam_starts_at_second"
Expand Down
17 changes: 0 additions & 17 deletions lib/tasks/tracks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,6 @@ namespace :tracks do
pbar.finish
end

desc 'Delete legacy `waveform_image`s from Tracks'
task delete_legacy_waveforms: :environment do
relation = Track.where.not(waveform_image_data: nil)
pbar = ProgressBar.create(
total: relation.size,
format: '%a %B %c/%C %p%% %E'
)

relation.find_each do |track|
track.waveform_image = nil
track.save!
pbar.increment
end

pbar.finish
end

desc 'Check for the same file being used for second occurrence of song within a show'
task find_dupe_filenames: :environment do
show_list = []
Expand Down
1 change: 0 additions & 1 deletion spec/factories/track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
set { '1' }
sequence(:position, 1)
audio_file_data { ShrineTestData.attachment_data('audio_file.mp3') }
waveform_image_data { ShrineTestData.attachment_data('waveform_image.png') }
waveform_png_data { ShrineTestData.attachment_data('waveform_image.png') }
duration { 1_000 }

Expand Down

0 comments on commit 7d8078e

Please sign in to comment.