Sha256: 2556f1cd210772cff072662cc0318d3c6c8a47d939d0c96259f6f989706091f1

Contents?: true

Size: 884 Bytes

Versions: 4

Compression:

Stored size: 884 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 :oauth_scope, type: String
  field :oauth_version, type: String, default: 'v1'
  field :active, type: Mongoid::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

4 entries across 4 versions & 1 rubygems

Version Path
slack-ruby-bot-server-2.1.1 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-2.1.0 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-2.0.1 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-1.2.1 lib/slack-ruby-bot-server/models/team/mongoid.rb