Sha256: c564ab98279d1b312a26e665e6e6c89041f32d06460991e219c2616bb46e3116

Contents?: true

Size: 788 Bytes

Versions: 5

Compression:

Stored size: 788 Bytes

Contents

require_relative 'methods'

class Team
  include Mongoid::Document
  include Mongoid::Timestamps

  field :team_id, type: String
  field :name, type: String
  field :domain, type: String
  field :token, type: String
  field :active, type: Boolean, default: true
  field :bot_user_id, type: String
  field :activated_user_id, type: String
  field :activated_user_access_token, type: String

  include Methods

  def self.purge!(dt = 2.weeks.ago)
    # destroy teams inactive for two weeks
    Team.where(active: false, :updated_at.lte => 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

5 entries across 5 versions & 1 rubygems

Version Path
slack-ruby-bot-server-1.1.0 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-1.0.0 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-0.12.3 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-0.12.2 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-0.12.1 lib/slack-ruby-bot-server/models/team/mongoid.rb