Commit c90d167b authored by Adam Niedzielski's avatar Adam Niedzielski

Create Member.expired scope.

parent 08ecf0e7
...@@ -31,6 +31,7 @@ class Member < ActiveRecord::Base ...@@ -31,6 +31,7 @@ class Member < ActiveRecord::Base
scope :non_invite, -> { where(invite_token: nil) } scope :non_invite, -> { where(invite_token: nil) }
scope :request, -> { where.not(requested_at: nil) } scope :request, -> { where.not(requested_at: nil) }
scope :has_access, -> { where('access_level > 0') } scope :has_access, -> { where('access_level > 0') }
scope :expired, -> { where('expires_at <= ?', Time.current) }
scope :guests, -> { where(access_level: GUEST) } scope :guests, -> { where(access_level: GUEST) }
scope :reporters, -> { where(access_level: REPORTER) } scope :reporters, -> { where(access_level: REPORTER) }
......
...@@ -2,7 +2,7 @@ class RemoveExpiredMembersWorker ...@@ -2,7 +2,7 @@ class RemoveExpiredMembersWorker
include Sidekiq::Worker include Sidekiq::Worker
def perform def perform
Member.where('expires_at <= ?', Time.current).find_each do |member| Member.expired.find_each do |member|
begin begin
Members::AuthorizedDestroyService.new(member).execute Members::AuthorizedDestroyService.new(member).execute
rescue => ex rescue => ex
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment