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
|
|
|
|
2019-10-31 23:06:26 -04:00
|
|
|
releases = @project.releases
|
|
|
|
releases = releases.preloaded if preload
|
|
|
|
releases.sorted
|
2018-12-13 06:08:53 -05:00
|
|
|
end
|
|
|
|
end
|