2018-12-13 06:08:53 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ReleasesFinder
|
|
|
|
def initialize(project, current_user = nil)
|
|
|
|
@project = project
|
|
|
|
@current_user = current_user
|
|
|
|
end
|
|
|
|
|
2019-10-31 23:06:26 -04:00
|
|
|
def execute(preload: true)
|
2018-12-21 09:51:46 -05:00
|
|
|
return Release.none unless Ability.allowed?(@current_user, :read_release, @project)
|
2018-12-13 06:08:53 -05:00
|
|
|
|
2020-03-24 20:08:11 -04:00
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/-/issues/211988
|
|
|
|
releases = @project.releases.where.not(tag: nil) # rubocop:disable CodeReuse/ActiveRecord
|
2019-10-31 23:06:26 -04:00
|
|
|
releases = releases.preloaded if preload
|
|
|
|
releases.sorted
|
2018-12-13 06:08:53 -05:00
|
|
|
end
|
|
|
|
end
|