Relocate API::Helpers::Packages::Nuget::MetadataPresenterHelpers
Summary
Follow up of !30726 (comment 338032661)
On Nuget API presenters, they are a collection of functions that are shared by several presenters class. This is due to some duplication in the json structure used by the different API endpoints.
For example, on the metadata endpoints a tags
field is present and is computed out of a collection of Package::Tag
s. On the search endpoint, a tags
field is also present and is computed in the same way. Both fields reference the same and unique function (tags_for
)
These shared functions have been centralized in a helper class: API::Helpers::Packages::Nuget::MetadataPresenterHelpers
.
The problem is that presenter live in Packages::Nuget::XPresenter
and they are accessing API::Helpers::Packages::XXX
, which doesn't make sense.
Improvements
- Relocate the helper class
API::Helpers::Packages::Nuget::MetadataPresenterHelpers
toPackages::Nuget::PresenterHelpers
inee/app/presenters/packages/nuget/
A better location might be available.
Risks
The improvement being a code move, the risks are minimal. Nuget presenters are massively used by the test suite nuget_packages_spec.rb
Involved components
ee/lib/api/helpers/packages/nuget/metadata_presenter_helpers.rb
ee/app/presenters/packages/nuget/search_results_presenter.rb
ee/app/presenters/packages/nuget/package_metadata_presenter.rb
ee/app/presenters/packages/nuget/packages_metadata_presenter.rb