Sha256: 0c2443476e39e03a9e6c0fc6d526616a30bc504e84d10d001637869710c42bb6

Contents?: true

Size: 687 Bytes

Versions: 4

Compression:

Stored size: 687 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!
    # destroy teams inactive for two weeks
    Team.where(active: false, :updated_at.lte => 2.weeks.ago).each do |team|
      Mongoid.logger.info "Destroying #{team}, inactive since #{team.updated_at}, over two weeks ago."
      team.destroy
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.12.0 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-0.11.1 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-0.11.0 lib/slack-ruby-bot-server/models/team/mongoid.rb
slack-ruby-bot-server-0.10.0 lib/slack-ruby-bot-server/models/team/mongoid.rb