Class: APN::PullNotification

Inherits:
Base
  • Object
show all
Defined in:
lib/apn_on_rails/app/models/apn/pull_notification.rb

Class Method Summary collapse

Methods inherited from Base

table_name

Class Method Details

.all_since(app_id, since_date = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/apn_on_rails/app/models/apn/pull_notification.rb', line 19

def self.all_since(app_id, since_date=nil)
  if since_date
    res = all(:order => "created_at DESC", 
              :conditions => ["app_id = ? AND created_at > ? AND launch_notification = ?", app_id, since_date, false])
  else 
    res = all(:order => "created_at DESC", 
              :conditions => ["app_id = ? AND launch_notification = ?", app_id, false])
  end
end

.latest_since(app_id, since_date = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/apn_on_rails/app/models/apn/pull_notification.rb', line 6

def self.latest_since(app_id, since_date=nil)
  if since_date
    res = first(:order => "created_at DESC", 
                :conditions => ["app_id = ? AND created_at > ? AND launch_notification = ?", app_id, since_date, false])
  else
    res = first(:order => "created_at DESC", 
                :conditions => ["app_id = ? AND launch_notification = ?", app_id, true])
    res = first(:order => "created_at DESC", 
                :conditions => ["app_id = ? AND launch_notification = ?", app_id, false]) unless res
  end
  res
end