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

label.rb « entities « api « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dc147f33671bd1a5295bddc183ec07e010c1d1f8 (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
# frozen_string_literal: true

module API
  module Entities
    class Label < Entities::LabelBasic
      with_options if: lambda { |_, options| options[:with_counts] } do
        expose :open_issues_count do |label, options|
          label.open_issues_count(options[:current_user])
        end

        expose :closed_issues_count do |label, options|
          label.closed_issues_count(options[:current_user])
        end

        expose :open_merge_requests_count do |label, options|
          label.open_merge_requests_count(options[:current_user])
        end
      end

      expose :subscribed do |label, options|
        label.subscribed?(options[:current_user]) || (
          options[:parent].is_a?(::Project) && label.subscribed?(options[:current_user], options[:parent])
        )
      end
    end
  end
end