YaleSTC/shifts

View on GitHub
app/models/announcement.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Announcement < Notice

  scope :active, -> {where("start <= ? AND end is ? OR end > ?", Time.now.utc, nil, Time.now.utc) }
  scope :upcoming, -> {where("start > ?", Time.now.utc)}
  scope :ordered_by_start, order('start')

  def active?
    self.start <= Time.now && (self.end == nil || self.end > Time.now)
  end

end