class Eventifier::API::GetNotifications

Public Instance Methods

call() click to toggle source
Calls superclass method Eventifier::API::Base#call
# File lib/eventifier/api/get_notifications.rb, line 4
def call
  render 'eventifier/notifications/index',
    notifications: notifications, user: user

  super
end

Private Instance Methods

after() click to toggle source
# File lib/eventifier/api/get_notifications.rb, line 26
def after
  Time.zone.at params['after'].to_i
end
notifications() click to toggle source
# File lib/eventifier/api/get_notifications.rb, line 15
def notifications
  scope = user.notifications.order("eventifier_notifications.created_at DESC").limit(per_page)
  scope = scope.where("eventifier_notifications.created_at < ?", after) if params['after']
  scope = scope.where("eventifier_notifications.created_at > ?", since) if params['since']
  scope = scope.where(
    "eventifier_notifications.created_at > ?", user.notifications_last_read_at
  ) if params['recent']

  scope
end
per_page() click to toggle source
# File lib/eventifier/api/get_notifications.rb, line 30
def per_page
  (params['limit'] || 5).to_i
end
since() click to toggle source
# File lib/eventifier/api/get_notifications.rb, line 34
def since
  Time.zone.at params['since'].to_i
end