Class: TentD::Notifications

Inherits:
Object
  • Object
show all
Defined in:
lib/tentd/notifications.rb,
lib/tentd/notifications/sidekiq.rb,
lib/tentd/notifications/girl_friday.rb

Defined Under Namespace

Classes: NotifyEntityWorker, NotifyWorker, ProfileInfoUpdateWorker, TriggerWorker, UpdateFollowingProfileWorker

Constant Summary collapse

TRIGGER_QUEUE =
GirlFriday::WorkQueue.new(:trigger) do |msg|
  Model::NotificationSubscription.notify_all(msg[:type], msg[:post_id])
end
NOTIFY_QUEUE =
GirlFriday::WorkQueue.new(:notify) do |msg|
  Model::NotificationSubscription.first(:id => msg[:subscription_id]).notify_about(msg[:post_id], msg[:view])
end
NOTIFY_ENTITY_QUEUE =
GirlFriday::WorkQueue.new(:notify_entity) do |msg|
  Model::NotificationSubscription.notify_entity(msg[:entity], msg[:post_id])
end
UPDATE_FOLLOWING_PROFILE_QUEUE =
GirlFriday::WorkQueue.new(:update_following_profile) do |msg|
  Model::Following.update_profile(msg[:following_id])
end
PROFILE_INFO_UPDATE_QUEUE =
GirlFriday::WorkQueue.new(:profile_info_update) do |msg|
  Model::ProfileInfo.create_update_post(msg[:profile_info_id])
end

Class Method Summary collapse

Class Method Details

.method_missing(*args) ⇒ Object

current job types

- trigger
- notify
- notify_entity
- update_following_profile
- profile_info_update


9
10
11
# File 'lib/tentd/notifications.rb', line 9

def self.method_missing(*args)
  send(:queue_job, *args)
end

.queue_job(job, msg) ⇒ Object



6
7
8
# File 'lib/tentd/notifications/sidekiq.rb', line 6

def self.queue_job(job, msg)
  const_get(job.to_s.split('_').map(&:capitalize).push('Worker').join).perform_async(msg)
end