Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/components/projects/ml/models_index_component.rb')
-rw-r--r--app/components/projects/ml/models_index_component.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/components/projects/ml/models_index_component.rb b/app/components/projects/ml/models_index_component.rb
new file mode 100644
index 00000000000..c5c20565195
--- /dev/null
+++ b/app/components/projects/ml/models_index_component.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Projects
+ module Ml
+ class ModelsIndexComponent < ViewComponent::Base
+ attr_reader :models
+
+ def initialize(models:)
+ @models = models
+ end
+
+ private
+
+ def view_model
+ Gitlab::Json.generate({ models: models_view_model })
+ end
+
+ def models_view_model
+ models.map(&:present).map do |m|
+ {
+ name: m.name,
+ version: m.latest_version_name,
+ path: m.latest_package_path
+ }
+ end
+ end
+ end
+ end
+end