diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-27 21:07:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-27 21:07:34 +0300 |
commit | 7dd130e2cae40514f02b02922251b62302f2fdd5 (patch) | |
tree | fd2f91802a2dd2659b72d3767ea9a00786d7900b /app/presenters/ml | |
parent | 9979d2afd66e12d938ea55372dcf2d8105b5eaca (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/presenters/ml')
-rw-r--r-- | app/presenters/ml/model_presenter.rb | 17 | ||||
-rw-r--r-- | app/presenters/ml/models_index_presenter.rb | 29 |
2 files changed, 17 insertions, 29 deletions
diff --git a/app/presenters/ml/model_presenter.rb b/app/presenters/ml/model_presenter.rb new file mode 100644 index 00000000000..1317a13351b --- /dev/null +++ b/app/presenters/ml/model_presenter.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Ml + class ModelPresenter < Gitlab::View::Presenter::Delegated + presents ::Ml::Model, as: :model + + def latest_version_name + model.latest_version&.version + end + + def latest_package_path + return unless model.latest_version&.package_id.present? + + Gitlab::Routing.url_helpers.project_package_path(model.project, model.latest_version.package_id) + end + end +end diff --git a/app/presenters/ml/models_index_presenter.rb b/app/presenters/ml/models_index_presenter.rb deleted file mode 100644 index c61f87fc4af..00000000000 --- a/app/presenters/ml/models_index_presenter.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -module Ml - class ModelsIndexPresenter - def initialize(models) - @models = models - end - - def present - data = @models.map do |m| - { - name: m.name, - version: m.latest_version&.version, - path: package_path(m) - } - end - - Gitlab::Json.generate({ models: data }) - end - - private - - def package_path(model) - return unless model.latest_version&.package.present? - - Gitlab::Routing.url_helpers.project_package_path(model.project, model.latest_version.package_id) - end - end -end |