Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions app/models/scheduled_show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ScheduledShow < ActiveRecord::Base
has_attached_file :image,
styles: { :thumb => "x300", :medium => "x600" },
path: ":attachment/:style/:basename.:extension",
validate_media_type: false # TODO comment out for prod
validate_media_type: false # TODO comment out for prod ???? idk
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/

has_many :scheduled_show_labels, dependent: :destroy
Expand Down Expand Up @@ -163,6 +163,17 @@ def url
"https://datafruits.fm/shows/#{self.show_series.slug}/episodes/#{self.slug}"
end

def maybe_add_to_default_playlist
if self.archive_published? && self.tracks.any?
self.tracks.each do |t|
unless self.radio.default_playlist.tracks.include? t
self.radio.default_playlist.tracks << t
Notification.create notification_type: "new_podcast", user: self.performers.first, source: self, send_to_chat: true, send_to_user: false, url: url
end
end
end
end

private

def add_performers
Expand Down Expand Up @@ -201,17 +212,6 @@ def end_at_cannot_be_before_start_at
end
end

def maybe_add_to_default_playlist
if self.archive_published?
self.tracks.each do |t|
unless self.radio.default_playlist.tracks.include? t
self.radio.default_playlist.tracks << t
Notification.create notification_type: "new_podcast", user: self.performers.first, source: self, send_to_chat: true, send_to_user: false, url: url
end
end
end
end

def maybe_process_recording
if self.recording && self.recording.processing_status === 'unprocessed'
ProcessRecordingWorker.perform_later self.recording.id, self.id
Expand Down
1 change: 1 addition & 0 deletions app/services/process_recording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def perform recording, scheduled_show= nil
if scheduled_show.present?
# grab scheduled show's info to use metadata and artwork
track.update scheduled_show_id: scheduled_show.id, title: scheduled_show.formatted_episode_title
scheduled_show.maybe_add_to_default_playlist
end
StreamingExpAwardWorker.set(wait: 15.minute).perform_later(track.id)
rescue Exception => e
Expand Down
2 changes: 2 additions & 0 deletions spec/models/scheduled_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@
end

expect(@scheduled_show.radio.default_playlist.tracks.include?(@scheduled_show.tracks.first)).to eq true

expect(Notification.last.notification_type).to eq("new_podcast")
end
end

Expand Down