Skip to content
代码片段 群组 项目
提交 07a4734f 编辑于 作者: fdegier's avatar fdegier
浏览文件

Model Registry present latest SemVer instead of ID

Changelog: changed
上级 41878456
No related branches found
No related tags found
无相关合并请求
......@@ -29,7 +29,10 @@ class ModelVersion < ApplicationRecord
delegate :name, to: :model
scope :order_by_model_id_id_desc, -> { order('model_id, id DESC') }
scope :latest_by_model, -> { order_by_model_id_id_desc.select('DISTINCT ON (model_id) *') }
scope :latest_by_model, -> {
order(model_id: :desc, semver_major: :desc, semver_minor: :desc, semver_patch: :desc)
.select('DISTINCT ON (model_id) *')
}
scope :by_version, ->(version) { where("version LIKE ?", "#{sanitize_sql_like(version)}%") } # rubocop:disable GitlabSecurity/SqlInjection -- we are sanitizing
scope :for_model, ->(model) { where(project: model.project, model: model) }
scope :including_relations, -> { includes(:project, :model, :candidate) }
......
......@@ -199,7 +199,7 @@ client.get_latest_versions(model_name)
**Notes**
- Argument `stages` is ignored.
- Versions are ordered by last created.
- Versions are ordered by highest semantic version.
#### Logging metrics and parameters to a model version
......
......@@ -233,7 +233,7 @@
subject { described_class.latest_by_model }
it 'returns only the latest model version per model id' do
is_expected.to match_array([model_version4, model_version2])
is_expected.to match_array([model_version3, model_version2])
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册