completion-kit 0.27.4 → 0.27.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f36bc9d9d0e9aa1e0e6ed29dec74bef0021e112c1c2198f737313ccabd02c827
|
|
4
|
+
data.tar.gz: a3dd4f7b50e7bf96389b390fa985954fed6644b0cd33d1eda1edfa92613b6a04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74ca0f3de22ea9af05a5afc86771bad4e12e018d2342d76110fc699ad6630345cd7664c2e2169b98bf2c4120cfbd96369b98be42c425ea6206344e2348052819
|
|
7
|
+
data.tar.gz: 42ce6279ed741e065dbeb4e51dba9342f08e7059690852787fbd83a1e0b279435b867d92825f4714e9594c39e5fe117d92d1445a4d651db7f72896d86965501c
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
class DedupeAndUniqueIndexMetricVersions < ActiveRecord::Migration[8.1]
|
|
2
|
+
class MetricVersion < ActiveRecord::Base
|
|
3
|
+
self.table_name = "completion_kit_metric_versions"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class Review < ActiveRecord::Base
|
|
7
|
+
self.table_name = "completion_kit_reviews"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Agreement < ActiveRecord::Base
|
|
11
|
+
self.table_name = "completion_kit_agreements"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def up
|
|
15
|
+
collapse_duplicate_versions
|
|
16
|
+
collapse_extra_current
|
|
17
|
+
|
|
18
|
+
remove_index :completion_kit_metric_versions, name: "index_ck_metric_versions_on_metric_vnum", if_exists: true
|
|
19
|
+
add_index :completion_kit_metric_versions, [:metric_id, :version_number],
|
|
20
|
+
unique: true, name: "index_ck_metric_versions_on_metric_vnum"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def down
|
|
24
|
+
remove_index :completion_kit_metric_versions, name: "index_ck_metric_versions_on_metric_vnum", if_exists: true
|
|
25
|
+
add_index :completion_kit_metric_versions, [:metric_id, :version_number],
|
|
26
|
+
name: "index_ck_metric_versions_on_metric_vnum"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def collapse_duplicate_versions
|
|
32
|
+
MetricVersion.order(:id).pluck(:id, :metric_id, :version_number)
|
|
33
|
+
.group_by { |(_, metric_id, version_number)| [metric_id, version_number] }
|
|
34
|
+
.each_value do |group|
|
|
35
|
+
next if group.size < 2
|
|
36
|
+
|
|
37
|
+
canonical = group.first.first
|
|
38
|
+
losers = group.drop(1).map(&:first)
|
|
39
|
+
Review.where(metric_version_id: losers).update_all(metric_version_id: canonical)
|
|
40
|
+
Agreement.where(metric_version_id: losers).update_all(metric_version_id: canonical)
|
|
41
|
+
MetricVersion.where(id: losers).delete_all
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def collapse_extra_current
|
|
46
|
+
MetricVersion.where(current: true)
|
|
47
|
+
.order(metric_id: :asc, version_number: :desc, id: :desc)
|
|
48
|
+
.pluck(:id, :metric_id)
|
|
49
|
+
.group_by { |(_, metric_id)| metric_id }
|
|
50
|
+
.each_value do |rows|
|
|
51
|
+
next if rows.size < 2
|
|
52
|
+
|
|
53
|
+
MetricVersion.where(id: rows.drop(1).map(&:first)).update_all(current: false)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: completion-kit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.27.
|
|
4
|
+
version: 0.27.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Damien Bastin
|
|
@@ -480,6 +480,7 @@ files:
|
|
|
480
480
|
- db/migrate/20260706000001_add_expected_column_to_completion_kit_runs.rb
|
|
481
481
|
- db/migrate/20260708000001_add_api_version_to_completion_kit_provider_credentials.rb
|
|
482
482
|
- db/migrate/20260713000001_add_catalog_model_count_to_completion_kit_provider_credentials.rb
|
|
483
|
+
- db/migrate/20260715000001_dedupe_and_unique_index_metric_versions.rb
|
|
483
484
|
- lib/completion-kit.rb
|
|
484
485
|
- lib/completion_kit.rb
|
|
485
486
|
- lib/completion_kit/concurrency_check.rb
|