Commit 37c42f87 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '10io-fix-instance-vars-access-in-nuget-services' into 'master'

Fix instance variables access to several nuget services

See merge request gitlab-org/gitlab!25602
parents 58b1f41a b9888626
......@@ -6,8 +6,6 @@ module Packages
include API::Helpers::Packages::Nuget::MetadataPresenterHelpers
include Gitlab::Utils::StrongMemoize
attr_reader :packages
COUNT = 1.freeze
def initialize(packages)
......@@ -56,7 +54,7 @@ module Packages
def sorted_versions
strong_memoize(:sorted_versions) do
versions = packages.map(&:version).compact
versions = @packages.map(&:version).compact
VersionSorter.sort(versions)
end
end
......
......@@ -3,8 +3,6 @@
module Packages
module Nuget
class PackagesVersionsPresenter
attr_reader :packages
def initialize(packages)
@packages = packages
end
......
......@@ -5,8 +5,6 @@ module Packages
class ServiceIndexPresenter
include API::Helpers::RelatedResourcesHelpers
attr_reader :project
SERVICE_VERSIONS = {
download: %w[PackageBaseAddress/3.0.0],
search: %w[SearchQueryService SearchQueryService/3.0.0-beta SearchQueryService/3.0.0-rc],
......@@ -52,13 +50,13 @@ module Packages
end
def build_service_url(service_type)
base_path = api_v4_projects_packages_nuget_path(id: project.id)
base_path = api_v4_projects_packages_nuget_path(id: @project.id)
full_path = case service_type
when :download
api_v4_projects_packages_nuget_download_package_name_package_version_package_filename_path(
{
id: project.id,
id: @project.id,
package_name: nil,
package_version: nil,
package_filename: nil
......@@ -70,7 +68,7 @@ module Packages
when :metadata
api_v4_projects_packages_nuget_metadata_package_name_package_version_path(
{
id: project.id,
id: @project.id,
package_name: nil,
package_version: nil
},
......
......@@ -7,8 +7,6 @@ module Packages
ExtractionError = Class.new(StandardError)
attr_reader :package_file_id
XPATHS = {
package_name: '//xmlns:package/xmlns:metadata/xmlns:id',
package_version: '//xmlns:package/xmlns:metadata/xmlns:version'
......@@ -30,7 +28,7 @@ module Packages
def package_file
strong_memoize(:package_file) do
::Packages::PackageFile.find_by_id(package_file_id)
::Packages::PackageFile.find_by_id(@package_file_id)
end
end
......
......@@ -7,8 +7,6 @@ module Packages
InvalidMetadataError = Class.new(StandardError)
attr_reader :package_file
def initialize(package_file)
@package_file = package_file
end
......@@ -16,10 +14,10 @@ module Packages
def execute
raise InvalidMetadataError.new('package name and/or package version not found in metadata') unless valid_metadata?
package_file.transaction do
package_file.update!(
@package_file.transaction do
@package_file.update!(
file_name: package_filename,
file: package_file.file
file: @package_file.file
)
if existing_package_id
......@@ -37,15 +35,15 @@ module Packages
end
def link_to_existing_package
package_to_destroy = package_file.package
package_file.update!(package_id: existing_package_id)
package_to_destroy = @package_file.package
@package_file.update!(package_id: existing_package_id)
package_to_destroy.destroy!
end
def update_linked_package
return unless package_name && package_version
package_file.package.update!(
@package_file.package.update!(
name: package_name,
version: package_version
)
......@@ -53,12 +51,12 @@ module Packages
def existing_package_id
strong_memoize(:existing_package_id) do
package_file.project.packages
.nuget
.with_name(package_name)
.with_version(package_version)
.pluck_primary_key
.first
@package_file.project.packages
.nuget
.with_name(package_name)
.with_version(package_version)
.pluck_primary_key
.first
end
end
......@@ -72,7 +70,7 @@ module Packages
def metadata
strong_memoize(:metadata) do
::Packages::Nuget::MetadataExtractionService.new(package_file.id).execute
::Packages::Nuget::MetadataExtractionService.new(@package_file.id).execute
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment