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/experiment.rb')
-rw-r--r--app/models/ml/experiment.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/app/models/ml/experiment.rb b/app/models/ml/experiment.rb
index 7ef9c70ba7e..e4e9baac4c8 100644
--- a/app/models/ml/experiment.rb
+++ b/app/models/ml/experiment.rb
@@ -2,11 +2,33 @@
module Ml
class Experiment < ApplicationRecord
- validates :name, :iid, :project, presence: true
- validates :iid, :name, uniqueness: { scope: :project, message: "should be unique in the project" }
+ include AtomicInternalId
+
+ validates :name, :project, presence: true
+ validates :name, uniqueness: { scope: :project, message: "should be unique in the project" }
belongs_to :project
belongs_to :user
has_many :candidates, class_name: 'Ml::Candidate'
+
+ has_internal_id :iid, scope: :project
+
+ def artifact_location
+ 'not_implemented'
+ end
+
+ class << self
+ def by_project_id_and_iid(project_id, iid)
+ find_by(project_id: project_id, iid: iid)
+ end
+
+ def by_project_id_and_name(project_id, name)
+ find_by(project_id: project_id, name: name)
+ end
+
+ def has_record?(project_id, name)
+ where(project_id: project_id, name: name).exists?
+ end
+ end
end
end