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/models/ml/model.rb')
-rw-r--r--app/models/ml/model.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/ml/model.rb b/app/models/ml/model.rb
index fb15b9fea72..27f03ed5857 100644
--- a/app/models/ml/model.rb
+++ b/app/models/ml/model.rb
@@ -19,6 +19,11 @@ module Ml
has_one :latest_version, -> { latest_by_model }, class_name: 'Ml::ModelVersion', inverse_of: :model
scope :including_latest_version, -> { includes(:latest_version) }
+ scope :with_version_count, -> {
+ left_outer_joins(:versions)
+ .select("ml_models.*, count(ml_model_versions.id) as version_count")
+ .group(:id)
+ }
scope :by_project, ->(project) { where(project_id: project.id) }
def valid_default_experiment?
@@ -32,5 +37,9 @@ module Ml
create_with(default_experiment: experiment)
.find_or_create_by(project: project, name: name)
end
+
+ def self.by_project_id_and_id(project_id, id)
+ find_by(project_id: project_id, id: id)
+ end
end
end