Created
September 10, 2020 23:06
-
-
Save bearded-avenger/0ecdcadbf2915f9c749af37ea63328d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomerNotification < ApplicationRecord | |
belongs_to :site | |
belongs_to :customer | |
belongs_to :notifyable, polymorphic: true | |
acts_as_tenant :site | |
validates_uniqueness_to_tenant :customer_id, scope: [:notifyable_id, :notifyable_type] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TenantNotifyPlaylistFollowersJob < ApplicationJob | |
queue_as :default | |
def perform(playlist_item_id) | |
@playlist_item = PlaylistItem.find_by_id(playlist_item_id) | |
return unless @playlist_item.present? | |
@playlist = @playlist_item.playlist | |
return unless @playlist.present? | |
return unless @playlist.playlist_followers.exists? | |
@playlist.playlist_followers.find_each do |playlist_follower| | |
@playlist_item.customer_notifications.create!(site: @playlist.site, customer: playlist_follower.customer) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment