Sha256: 5a4350209cf7a8ab1ebe549e682fe2f5b0b024134449182e9ae2e57cd2a9ae43

Contents?: true

Size: 777 Bytes

Versions: 7

Compression:

Stored size: 777 Bytes

Contents

module SlackRubyBotServer
  module Api
    module Presenters
      module StatusPresenter
        include Roar::JSON::HAL
        include Roar::Hypermedia
        include Grape::Roar::Representer

        link :self do |opts|
          "#{base_url(opts)}/status"
        end

        property :teams_count
        property :active_teams_count
        property :ping

        private

        def ping
          team = Team.asc(:_id).first
          return unless team
          team.ping!
        end

        def teams_count
          Team.count
        end

        def active_teams_count
          Team.active.count
        end

        def base_url(opts)
          request = Grape::Request.new(opts[:env])
          request.base_url
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.5.0 lib/slack-ruby-bot-server/api/presenters/status_presenter.rb
slack-ruby-bot-server-0.4.0 lib/slack-ruby-bot-server/api/presenters/status_presenter.rb
slack-ruby-bot-server-0.3.1 lib/slack-ruby-bot-server/api/presenters/status_presenter.rb
slack-ruby-bot-server-0.3.0 lib/slack-ruby-bot-server/api/presenters/status_presenter.rb
slack-ruby-bot-server-0.2.0 lib/slack-ruby-bot-server/api/presenters/status_presenter.rb
slack-ruby-bot-server-0.1.1 lib/slack-ruby-bot-server/api/presenters/status_presenter.rb
slack-ruby-bot-server-0.1.0 lib/slack-ruby-bot-server/api/presenters/status_presenter.rb