gitlab-org--gitlab-foss/app/models/concerns/expirable.rb
Callum Dryden 9124310f28
Differentiate the expire from leave event
At the moment we cannot see weather a user left a project due to their
membership expiring of if they themselves opted to leave the project.
This adds a new event type that allows us to make this differentiation.
Note that is not really feasable to go back and reliably fix up the
previous events. As a result the events for previous expire removals
will remain the same however events of this nature going forward will be
correctly represented.
2016-10-20 00:26:45 +00:00

19 lines
323 B
Ruby

module Expirable
extend ActiveSupport::Concern
included do
scope :expired, -> { where('expires_at <= ?', Time.current) }
end
def expired?
expires? && expires_at <= Time.current
end
def expires?
expires_at.present?
end
def expires_soon?
expires? && expires_at < 7.days.from_now
end
end