Class: Resolvers::Analytics::CycleAnalytics::BaseCountResolver

Inherits:
BaseResolver
  • Object
show all
Defined in:
app/graphql/resolvers/analytics/cycle_analytics/base_count_resolver.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseResolver

as_single, authorization, authorized?, before_connection_authorization, before_connection_authorization_block, calculate_ext_conn_complexity, calls_gitaly!, calls_gitaly?, complexity, complexity_multiplier, #current_user, last, #object, #offset_pagination, requires_argument!, requires_argument?, resolver_complexity, #select_result, single, #single?, single_definition_blocks, singular_type, when_single

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Class Method Details

.[](context = :project) ⇒ Object

:project level: no customization, returning the original resolver :group level: add the project_ids argument



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/graphql/resolvers/analytics/cycle_analytics/base_count_resolver.rb', line 38

def self.[](context = :project)
  case context
  when :project
    self
  when :group
    Class.new(self) do
      argument :project_ids, [GraphQL::Types::ID],
        required: false,
        description: 'Project IDs within the group hierarchy.'

      define_method :finder_params do
        { group_id: object.id, include_subgroups: true }
      end
    end
  end
end

Instance Method Details

#ready?(**args) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/graphql/resolvers/analytics/cycle_analytics/base_count_resolver.rb', line 17

def ready?(**args)
  start_date = args[:from]
  end_date = args[:to]

  if start_date >= end_date
    raise Gitlab::Graphql::Errors::ArgumentError,
      '`from` argument must be before `to` argument'
  end

  max_days = Gitlab::Analytics::CycleAnalytics::RequestParams::MAX_RANGE_DAYS

  if (end_date.beginning_of_day - start_date.beginning_of_day) > max_days
    raise Gitlab::Graphql::Errors::ArgumentError,
      "Max of #{max_days.inspect} timespan is allowed"
  end

  super
end