Class: UserQ::UserQueue
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- UserQ::UserQueue
- Defined in:
- lib/userq.rb
Class Method Summary collapse
- .count_in_context(context) ⇒ Object
- .count_unexpired(context) ⇒ Object
- .empty(context) ⇒ Object
- .find_by_code(code) ⇒ Object
- .next_in_seconds(context) ⇒ Object
- .reset(context) ⇒ Object
Class Method Details
.count_in_context(context) ⇒ Object
165 166 167 |
# File 'lib/userq.rb', line 165 def self.count_in_context context where(context: context).count end |
.count_unexpired(context) ⇒ Object
161 162 163 |
# File 'lib/userq.rb', line 161 def self.count_unexpired context where(context: context).where("expires_at > ?", UserQ::Internal.current_time).count end |
.empty(context) ⇒ Object
178 179 180 |
# File 'lib/userq.rb', line 178 def self.empty context where(context: context).where("expires_at <= ?", UserQ::Internal.current_time).destroy_all end |
.find_by_code(code) ⇒ Object
157 158 159 |
# File 'lib/userq.rb', line 157 def self.find_by_code code where(code: code) end |
.next_in_seconds(context) ⇒ Object
173 174 175 176 |
# File 'lib/userq.rb', line 173 def self.next_in_seconds context seconds = (where(context: context).order(expires_at: :asc).first.expires_at - UserQ::Internal.current_time).to_i seconds > 0 ? seconds : 0 end |
.reset(context) ⇒ Object
169 170 171 |
# File 'lib/userq.rb', line 169 def self.reset context where(context: context).destroy_all end |