Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rugged.rb « views « peek « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b9d3e7b1a37bb9170c42b4f89528e8f2dbd8343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

module Peek
  module Views
    class Rugged < DetailedView
      def results
        return {} unless calls > 0

        super
      end

      private

      def duration
        ::Gitlab::RuggedInstrumentation.query_time
      end

      def calls
        ::Gitlab::RuggedInstrumentation.query_count
      end

      def call_details
        ::Gitlab::RuggedInstrumentation.list_call_details
      end

      def format_call_details(call)
        super.merge(args: format_args(call[:args]))
      end

      def format_args(args)
        args.map do |arg|
          # Needed to avoid infinite as_json calls
          if arg.is_a?(Gitlab::Git::Repository)
            arg.to_s
          else
            arg
          end
        end
      end
    end
  end
end