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

models_controller.rb « ml « projects « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4ff7d0147235e8d6a24f49c74ac1eae811a7283b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Projects
  module Ml
    class ModelsController < ::Projects::ApplicationController
      before_action :check_feature_enabled
      before_action :set_model, only: [:show]
      feature_category :mlops

      MAX_MODELS_PER_PAGE = 20

      def index
        @paginator = ::Projects::Ml::ModelFinder.new(@project)
                                                .execute
                                                .keyset_paginate(cursor: params[:cursor], per_page: MAX_MODELS_PER_PAGE)
      end

      def show; end

      private

      def check_feature_enabled
        render_404 unless can?(current_user, :read_model_registry, @project)
      end

      def set_model
        @model = ::Ml::Model.by_project_id_and_id(@project, params[:model_id])

        render_404 unless @model
      end
    end
  end
end