Class: Packages::Nuget::SearchService

Inherits:
BaseService show all
Includes:
ActiveRecord::ConnectionAdapters::Quoting, Gitlab::Utils::StrongMemoize, FinderHelper
Defined in:
app/services/packages/nuget/search_service.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

MAX_PER_PAGE =
30
MAX_VERSIONS_PER_PACKAGE =
10
PRE_RELEASE_VERSION_MATCHING_TERM =
'%-%'
DEFAULT_OPTIONS =
{
  include_prerelease_versions: true,
  per_page: Kaminari.config.default_per_page,
  padding: 0
}.freeze

Constants included from FinderHelper

FinderHelper::InvalidPackageTypeError, FinderHelper::InvalidStatusError

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(current_user, project_or_group, search_term, options = {}) ⇒ SearchService

Returns a new instance of SearchService.

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
28
# File 'app/services/packages/nuget/search_service.rb', line 20

def initialize(current_user, project_or_group, search_term, options = {})
  @current_user = current_user
  @project_or_group = project_or_group
  @search_term = search_term
  @options = DEFAULT_OPTIONS.merge(options)

  raise ArgumentError, 'negative per_page' if per_page < 0
  raise ArgumentError, 'negative padding' if padding < 0
end

Instance Method Details

#executeObject



30
31
32
33
34
35
# File 'app/services/packages/nuget/search_service.rb', line 30

def execute
  Result.new(
    total_count: non_paginated_matching_package_names.count,
    results: search_packages
  )
end