Sha256: 86b7e058702d88f4faad3433d687fe16425d4cf9a9eb2af9584b6ffb5e559365

Contents?: true

Size: 724 Bytes

Versions: 8

Compression:

Stored size: 724 Bytes

Contents

module Heartcheck
  module Controllers
    class Dev < Base
      def index
        results = []

        total_execution_time = time_diff do
          checks = Heartcheck.dev_checks

          results += checks.reduce([]) do |acc, elem|
            context_result = {}

            context_result['execution_time'] = time_diff do
              context_result.merge!(elem.check)
            end

            acc << context_result
          end
        end

        results << { 'total_execution_time' => total_execution_time }
        Oj.dump(results)
      end

      private

      def time_diff
        start_time = Time.now
        yield
        '%.2f ms' % ((Time.now - start_time) * 1_000)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
heartcheck-1.0.9 lib/heartcheck/controllers/dev.rb
heartcheck-1.0.8 lib/heartcheck/controllers/dev.rb
heartcheck-1.0.7 lib/heartcheck/controllers/dev.rb
heartcheck-1.0.6 lib/heartcheck/controllers/dev.rb
heartcheck-1.0.5 lib/heartcheck/controllers/dev.rb
heartcheck-1.0.4 lib/heartcheck/controllers/dev.rb
heartcheck-1.0.3 lib/heartcheck/controllers/dev.rb
heartcheck-1.0.0 lib/heartcheck/controllers/dev.rb