debian-mirror-gitlab/lib/gitlab/cycle_analytics/group_projects_provider.rb
2019-10-12 21:52:04 +05:30

27 lines
556 B
Ruby

# frozen_string_literal: true
module Gitlab
module CycleAnalytics
module GroupProjectsProvider
def projects
group ? projects_for_group : [project]
end
def group
@group ||= options.fetch(:group, nil)
end
def project
@project ||= options.fetch(:project, nil)
end
private
def projects_for_group
projects = Project.inside_path(group.full_path)
projects = projects.where(id: options[:projects]) if options[:projects]
projects
end
end
end
end