summaryrefslogtreecommitdiff
path: root/app/finders/packages
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/packages')
-rw-r--r--app/finders/packages/group_packages_finder.rb30
-rw-r--r--app/finders/packages/nuget/package_finder.rb2
-rw-r--r--app/finders/packages/packages_finder.rb21
3 files changed, 8 insertions, 45 deletions
diff --git a/app/finders/packages/group_packages_finder.rb b/app/finders/packages/group_packages_finder.rb
index 860c4068b31..db5161d6e16 100644
--- a/app/finders/packages/group_packages_finder.rb
+++ b/app/finders/packages/group_packages_finder.rb
@@ -2,9 +2,7 @@
module Packages
class GroupPackagesFinder
- attr_reader :current_user, :group, :params
-
- InvalidPackageTypeError = Class.new(StandardError)
+ include ::Packages::FinderHelper
def initialize(current_user, group, params = { exclude_subgroups: false, order_by: 'created_at', sort: 'asc' })
@current_user = current_user
@@ -20,6 +18,8 @@ module Packages
private
+ attr_reader :current_user, :group, :params
+
def packages_for_group_projects
packages = ::Packages::Package
.including_build_info
@@ -32,6 +32,7 @@ module Packages
packages = filter_with_version(packages)
packages = filter_by_package_type(packages)
packages = filter_by_package_name(packages)
+ packages = filter_by_status(packages)
packages
end
@@ -46,10 +47,6 @@ module Packages
.with_feature_available_for_user(:repository, current_user)
end
- def package_type
- params[:package_type].presence
- end
-
def groups
return [group] if exclude_subgroups?
@@ -59,24 +56,5 @@ module Packages
def exclude_subgroups?
params[:exclude_subgroups]
end
-
- def filter_by_package_type(packages)
- return packages unless package_type
- raise InvalidPackageTypeError unless Package.package_types.key?(package_type)
-
- packages.with_package_type(package_type)
- end
-
- def filter_by_package_name(packages)
- return packages unless params[:package_name].present?
-
- packages.search_by_name(params[:package_name])
- end
-
- def filter_with_version(packages)
- return packages if params[:include_versionless].present?
-
- packages.has_version
- end
end
end
diff --git a/app/finders/packages/nuget/package_finder.rb b/app/finders/packages/nuget/package_finder.rb
index 8f585f045a1..2f66bd145ee 100644
--- a/app/finders/packages/nuget/package_finder.rb
+++ b/app/finders/packages/nuget/package_finder.rb
@@ -5,7 +5,7 @@ module Packages
class PackageFinder
include ::Packages::FinderHelper
- MAX_PACKAGES_COUNT = 50
+ MAX_PACKAGES_COUNT = 300
def initialize(current_user, project_or_group, package_name:, package_version: nil, limit: MAX_PACKAGES_COUNT)
@current_user = current_user
diff --git a/app/finders/packages/packages_finder.rb b/app/finders/packages/packages_finder.rb
index 72a63224d2f..bd9e62e3f2a 100644
--- a/app/finders/packages/packages_finder.rb
+++ b/app/finders/packages/packages_finder.rb
@@ -2,7 +2,7 @@
module Packages
class PackagesFinder
- attr_reader :params, :project
+ include ::Packages::FinderHelper
def initialize(project, params = {})
@project = project
@@ -21,29 +21,14 @@ module Packages
packages = filter_with_version(packages)
packages = filter_by_package_type(packages)
packages = filter_by_package_name(packages)
+ packages = filter_by_status(packages)
packages = order_packages(packages)
packages
end
private
- def filter_with_version(packages)
- return packages if params[:include_versionless].present?
-
- packages.has_version
- end
-
- def filter_by_package_type(packages)
- return packages unless params[:package_type]
-
- packages.with_package_type(params[:package_type])
- end
-
- def filter_by_package_name(packages)
- return packages unless params[:package_name]
-
- packages.search_by_name(params[:package_name])
- end
+ attr_reader :params, :project
def order_packages(packages)
packages.sort_by_attribute("#{params[:order_by]}_#{params[:sort]}")