Sha256: f4b5e8e6d2af1c871eb0b0b8ee36ce54661444b3ff9e93e70796cba4aabab98f

Contents?: true

Size: 421 Bytes

Versions: 10

Compression:

Stored size: 421 Bytes

Contents

require_relative 'methods'

class Team < ActiveRecord::Base
  include Methods

  def self.purge!(dt = 2.weeks.ago)
    Team.where(active: false).where('updated_at <= ?', dt).each do |team|
      begin
        logger.info "Destroying #{team}, inactive since #{team.updated_at}."
        team.destroy
      rescue StandardError => e
        logger.warn "Error destroying #{team}, #{e.message}."
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
slack-ruby-bot-server-2.1.1 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-2.1.0 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-2.0.1 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-1.2.1 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-1.2.0 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-1.1.0 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-1.0.0 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-0.12.3 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-0.12.2 lib/slack-ruby-bot-server/models/team/activerecord.rb
slack-ruby-bot-server-0.12.1 lib/slack-ruby-bot-server/models/team/activerecord.rb