pact_broker 2.15.0 → 2.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +7 -3
- data/CHANGELOG.md +53 -0
- data/DEVELOPER_DOCUMENTATION.md +28 -1
- data/DEVELOPER_SETUP.md +1 -1
- data/README.md +8 -5
- data/db/migrations/000004_create_tags_table.rb +1 -1
- data/db/migrations/000050_create_latest_matrix.rb +1 -0
- data/db/migrations/20180122_create_head_pact_publications.rb +21 -0
- data/db/migrations/20180123_create_tags_with_latest_flag.rb +28 -0
- data/db/migrations/20180129_create_latest_matrix_for_cv_and_pv.rb +91 -0
- data/db/migrations/20180130_create_materialized_matrix.rb +35 -0
- data/db/migrations/20180131_create_materialized_latest_matrix.rb +35 -0
- data/db/migrations/20180201_create_head_matrix.rb +33 -0
- data/db/migrations/20180202_create_materialized_head_matrix.rb +34 -0
- data/db/migrations/20180203_fix_head_matrix.rb +36 -0
- data/db/migrations/20180204_fix_latest_matrix_for_cv_and_pv.rb +57 -0
- data/db/migrations/20180205_drop_materialized_latest_matrix.rb +36 -0
- data/db/migrations/20180206_recreate_head_matrix_rename_consumer_tag_name.rb +68 -0
- data/db/migrations/20180207_recreate_head_matrix_union_all.rb +60 -0
- data/db/migrations/20180208_add_cv_tag_name_index_to_mat_head_matrix.rb +7 -0
- data/db/migrations/20180209_recreate_latest_matrix_for_cv_and_pv_union_all.rb +54 -0
- data/db/migrations/20180210_fix_latest_matrix_for_cv_and_pv_again.rb +53 -0
- data/db/migrations/migration_helper.rb +8 -0
- data/db/test/backwards_compatibility/Rakefile +1 -1
- data/example/pact_broker_database.sqlite3 +0 -0
- data/lib/pact_broker/api.rb +1 -0
- data/lib/pact_broker/api/decorators/dashboard_decorator.rb +163 -0
- data/lib/pact_broker/api/decorators/dashboard_text_decorator.rb +50 -0
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +21 -16
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +1 -0
- data/lib/pact_broker/api/pact_broker_urls.rb +29 -0
- data/lib/pact_broker/api/resources/base_resource.rb +3 -0
- data/lib/pact_broker/api/resources/dashboard.rb +38 -0
- data/lib/pact_broker/api/resources/label.rb +0 -1
- data/lib/pact_broker/api/resources/tag.rb +0 -1
- data/lib/pact_broker/dashboard/service.rb +0 -0
- data/lib/pact_broker/domain/index_item.rb +16 -5
- data/lib/pact_broker/index/service.rb +69 -4
- data/lib/pact_broker/matrix/head_row.rb +11 -0
- data/lib/pact_broker/matrix/latest_row.rb +2 -16
- data/lib/pact_broker/matrix/repository.rb +56 -11
- data/lib/pact_broker/matrix/row.rb +166 -6
- data/lib/pact_broker/matrix/service.rb +5 -0
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +18 -0
- data/lib/pact_broker/ui/controllers/index.rb +5 -2
- data/lib/pact_broker/ui/controllers/matrix.rb +3 -3
- data/lib/pact_broker/ui/view_models/index_item.rb +13 -5
- data/lib/pact_broker/ui/view_models/matrix_line.rb +77 -8
- data/lib/pact_broker/ui/view_models/matrix_lines.rb +17 -0
- data/lib/pact_broker/ui/view_models/matrix_tag.rb +42 -0
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +26 -14
- data/lib/pact_broker/ui/views/index/show.haml +9 -8
- data/lib/pact_broker/ui/views/matrix/show.haml +46 -15
- data/lib/pact_broker/verifications/latest_verifications_by_consumer_version.rb +1 -0
- data/lib/pact_broker/verifications/repository.rb +4 -4
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/abbreviate_number.rb +14 -0
- data/pact_broker.gemspec +3 -2
- data/public/images/logo@2x.png +0 -0
- data/public/javascripts/matrix.js +5 -0
- data/public/stylesheets/index.css +33 -1
- data/public/stylesheets/matrix.css +9 -0
- data/script/db-spec.sh +1 -1
- data/spec/features/get_dashboard_spec.rb +29 -0
- data/spec/fixtures/dashboard.json +83 -0
- data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +89 -0
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +30 -26
- data/spec/lib/pact_broker/api/resources/dashboard_spec.rb +16 -0
- data/spec/lib/pact_broker/api/resources/group_spec.rb +1 -0
- data/spec/lib/pact_broker/index/service_spec.rb +146 -32
- data/spec/lib/pact_broker/matrix/repository_spec.rb +48 -1
- data/spec/lib/pact_broker/matrix/row_spec.rb +59 -0
- data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +17 -12
- data/spec/lib/pact_broker/versions/abbreviate_number_spec.rb +22 -0
- data/spec/migrations/20180201_create_head_matrix_spec.rb +132 -0
- data/spec/migrations/23_pact_versions_spec.rb +2 -2
- data/spec/migrations/50_create_latest_matrix_spec.rb +84 -16
- data/spec/migrations/change_migration_strategy_spec.rb +1 -1
- data/spec/service_consumers/pact_helper.rb +4 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/migration_helpers.rb +1 -1
- data/spec/support/rspec_match_hash.rb +6 -2
- data/spec/support/shared_examples_for_responses.rb +1 -1
- data/spec/support/test_data_builder.rb +61 -11
- metadata +57 -6
@@ -0,0 +1,34 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
create_table(:materialized_head_matrix, charset: 'utf8') do
|
4
|
+
Integer :consumer_id, null: false
|
5
|
+
String :consumer_name, null: false
|
6
|
+
Integer :consumer_version_id, null: false
|
7
|
+
String :consumer_version_number, null: false
|
8
|
+
Integer :consumer_version_order, null: false
|
9
|
+
Integer :pact_publication_id, null: false
|
10
|
+
Integer :pact_version_id, null: false
|
11
|
+
String :pact_version_sha, null: false
|
12
|
+
Integer :pact_revision_number, null: false
|
13
|
+
DateTime :pact_created_at, null: false
|
14
|
+
Integer :provider_id, null: false
|
15
|
+
String :provider_name, null: false
|
16
|
+
Integer :provider_version_id
|
17
|
+
String :provider_version_number
|
18
|
+
Integer :provider_version_order
|
19
|
+
Integer :verification_id
|
20
|
+
Boolean :success
|
21
|
+
Integer :verification_number
|
22
|
+
DateTime :verification_executed_at
|
23
|
+
String :verification_build_url
|
24
|
+
String :consumer_tag_name
|
25
|
+
index [:consumer_id], name: 'ndx_mhm_consumer_id'
|
26
|
+
index [:provider_id], name: 'ndx_mhm_provider_id'
|
27
|
+
index [:consumer_version_order], name: 'ndx_mhm_cv_ord'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
down do
|
32
|
+
drop_table(:materialized_head_matrix)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# A row for each of the latest pact publications,
|
4
|
+
# and a row for each of the latest tagged pact publications.
|
5
|
+
# This definition fixes the missing revision number join in
|
6
|
+
# 20180201_create_head_matrix.rb
|
7
|
+
create_or_replace_view(:head_matrix,
|
8
|
+
"SELECT matrix.*, hpp.tag_name as consumer_tag_name
|
9
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
10
|
+
INNER JOIN head_pact_publications hpp
|
11
|
+
ON matrix.consumer_id = hpp.consumer_id
|
12
|
+
AND matrix.provider_id = hpp.provider_id
|
13
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
14
|
+
AND matrix.pact_revision_number = hpp.revision_number
|
15
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider AS lv
|
16
|
+
ON matrix.consumer_version_id = lv.consumer_version_id
|
17
|
+
AND matrix.provider_id = lv.provider_id
|
18
|
+
AND matrix.verification_id = lv.latest_verification_id
|
19
|
+
|
20
|
+
UNION
|
21
|
+
|
22
|
+
SELECT matrix.*, hpp.tag_name as consumer_tag_name
|
23
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
24
|
+
INNER JOIN head_pact_publications hpp
|
25
|
+
ON matrix.consumer_id = hpp.consumer_id
|
26
|
+
AND matrix.provider_id = hpp.provider_id
|
27
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
28
|
+
AND matrix.pact_revision_number = hpp.revision_number
|
29
|
+
where verification_id is null
|
30
|
+
"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
down do
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# Removes 'overwritten' pacts and verifications from the matrix
|
4
|
+
# (ie. only show latest pact revision for each consumer version and
|
5
|
+
# latest verification for each provider version)
|
6
|
+
# Must include lines where verification_id is null so that we don't
|
7
|
+
# lose the unverified pacts.
|
8
|
+
# In this view there will be one row for each consumer version/provider version
|
9
|
+
# This view used to be (stupidly) called latest_matrix
|
10
|
+
create_or_replace_view(:latest_matrix_for_consumer_version_and_provider_version,
|
11
|
+
"
|
12
|
+
SELECT matrix.* FROM matrix
|
13
|
+
inner join latest_pact_publication_revision_numbers lr
|
14
|
+
on matrix.consumer_id = lr.consumer_id
|
15
|
+
and matrix.provider_id = lr.provider_id
|
16
|
+
and matrix.consumer_version_order = lr.consumer_version_order
|
17
|
+
and matrix.pact_revision_number = lr.latest_revision_number
|
18
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider_version AS lv
|
19
|
+
ON ((matrix.consumer_version_id = lv.consumer_version_id)
|
20
|
+
AND (matrix.provider_version_id = lv.provider_version_id)
|
21
|
+
AND ((matrix.verification_id = lv.latest_verification_id)))
|
22
|
+
|
23
|
+
UNION
|
24
|
+
|
25
|
+
select matrix.* from matrix
|
26
|
+
inner join latest_pact_publication_revision_numbers lr
|
27
|
+
on matrix.consumer_id = lr.consumer_id
|
28
|
+
and matrix.provider_id = lr.provider_id
|
29
|
+
and matrix.consumer_version_order = lr.consumer_version_order
|
30
|
+
and matrix.pact_revision_number = lr.latest_revision_number
|
31
|
+
where verification_id is null
|
32
|
+
"
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
down do
|
37
|
+
# revert to dodgey definition
|
38
|
+
create_or_replace_view(:latest_matrix_for_consumer_version_and_provider_version,
|
39
|
+
"SELECT matrix.* FROM matrix
|
40
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider_version AS lv
|
41
|
+
ON ((matrix.consumer_version_id = lv.consumer_version_id)
|
42
|
+
AND (matrix.provider_version_id = lv.provider_version_id)
|
43
|
+
AND ((matrix.verification_id = lv.latest_verification_id)))
|
44
|
+
|
45
|
+
UNION
|
46
|
+
|
47
|
+
select matrix.* from matrix
|
48
|
+
inner join latest_pact_publication_revision_numbers lr
|
49
|
+
on matrix.consumer_id = lr.consumer_id
|
50
|
+
and matrix.provider_id = lr.provider_id
|
51
|
+
and matrix.consumer_version_order = lr.consumer_version_order
|
52
|
+
and matrix.pact_revision_number = lr.latest_revision_number
|
53
|
+
where verification_id is null
|
54
|
+
"
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# removing this as it has been replaced by materialized_head_matrix
|
4
|
+
drop_table(:materialized_latest_matrix)
|
5
|
+
end
|
6
|
+
|
7
|
+
down do
|
8
|
+
create_table(:materialized_latest_matrix, charset: 'utf8') do
|
9
|
+
Integer :consumer_id, null: false
|
10
|
+
String :consumer_name, null: false
|
11
|
+
Integer :consumer_version_id, null: false
|
12
|
+
String :consumer_version_number, null: false
|
13
|
+
Integer :consumer_version_order, null: false
|
14
|
+
Integer :pact_publication_id, null: false
|
15
|
+
Integer :pact_version_id, null: false
|
16
|
+
String :pact_version_sha, null: false
|
17
|
+
Integer :pact_revision_number, null: false
|
18
|
+
DateTime :pact_created_at, null: false
|
19
|
+
Integer :provider_id, null: false
|
20
|
+
String :provider_name, null: false
|
21
|
+
Integer :provider_version_id
|
22
|
+
String :provider_version_number
|
23
|
+
Integer :provider_version_order
|
24
|
+
Integer :verification_id
|
25
|
+
Boolean :success
|
26
|
+
Integer :verification_number
|
27
|
+
DateTime :verification_executed_at
|
28
|
+
String :verification_build_url
|
29
|
+
index [:consumer_id], name: 'ndx_mlm_consumer_id'
|
30
|
+
index [:provider_id], name: 'ndx_mlm_provider_id'
|
31
|
+
index [:consumer_version_order], name: 'ndx_mlm_cv_ord'
|
32
|
+
end
|
33
|
+
|
34
|
+
from(:materialized_latest_matrix).insert(from(:latest_matrix).select_all)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# a row for each of the latest pact publications,
|
4
|
+
# and a row for each of the latest tagged pact publications
|
5
|
+
drop_view(:head_matrix)
|
6
|
+
create_view(:head_matrix,
|
7
|
+
"SELECT matrix.*, hpp.tag_name as consumer_version_tag_name
|
8
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
9
|
+
INNER JOIN head_pact_publications hpp
|
10
|
+
ON matrix.consumer_id = hpp.consumer_id
|
11
|
+
AND matrix.provider_id = hpp.provider_id
|
12
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
13
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider AS lv
|
14
|
+
ON matrix.consumer_version_id = lv.consumer_version_id
|
15
|
+
AND matrix.provider_id = lv.provider_id
|
16
|
+
AND matrix.verification_id = lv.latest_verification_id
|
17
|
+
|
18
|
+
UNION
|
19
|
+
|
20
|
+
SELECT matrix.*, hpp.tag_name as consumer_version_tag_name
|
21
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
22
|
+
INNER JOIN head_pact_publications hpp
|
23
|
+
ON matrix.consumer_id = hpp.consumer_id
|
24
|
+
AND matrix.provider_id = hpp.provider_id
|
25
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
26
|
+
where verification_id is null
|
27
|
+
"
|
28
|
+
)
|
29
|
+
|
30
|
+
alter_table(:materialized_head_matrix) do
|
31
|
+
rename_column(:consumer_tag_name, :consumer_version_tag_name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
down do
|
36
|
+
alter_table(:materialized_head_matrix) do
|
37
|
+
rename_column(:consumer_version_tag_name, :consumer_tag_name)
|
38
|
+
end
|
39
|
+
|
40
|
+
drop_view(:head_matrix)
|
41
|
+
create_view(:head_matrix,
|
42
|
+
"SELECT matrix.*, hpp.tag_name as consumer_tag_name
|
43
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
44
|
+
INNER JOIN head_pact_publications hpp
|
45
|
+
ON matrix.consumer_id = hpp.consumer_id
|
46
|
+
AND matrix.provider_id = hpp.provider_id
|
47
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
48
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider AS lv
|
49
|
+
ON matrix.consumer_version_id = lv.consumer_version_id
|
50
|
+
AND matrix.provider_id = lv.provider_id
|
51
|
+
AND matrix.verification_id = lv.latest_verification_id
|
52
|
+
|
53
|
+
UNION
|
54
|
+
|
55
|
+
SELECT matrix.*, hpp.tag_name as consumer_tag_name
|
56
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
57
|
+
INNER JOIN head_pact_publications hpp
|
58
|
+
ON matrix.consumer_id = hpp.consumer_id
|
59
|
+
AND matrix.provider_id = hpp.provider_id
|
60
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
61
|
+
where verification_id is null
|
62
|
+
"
|
63
|
+
)
|
64
|
+
|
65
|
+
from(:materialized_head_matrix).delete
|
66
|
+
from(:materialized_head_matrix).insert(from(:head_matrix).select_all)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# a row for each of the latest pact publications,
|
4
|
+
# and a row for each of the latest tagged pact publications
|
5
|
+
drop_view(:head_matrix)
|
6
|
+
create_view(:head_matrix,
|
7
|
+
"SELECT matrix.*, hpp.tag_name as consumer_version_tag_name
|
8
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
9
|
+
INNER JOIN head_pact_publications hpp
|
10
|
+
ON matrix.consumer_id = hpp.consumer_id
|
11
|
+
AND matrix.provider_id = hpp.provider_id
|
12
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
13
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider AS lv
|
14
|
+
ON matrix.consumer_version_id = lv.consumer_version_id
|
15
|
+
AND matrix.provider_id = lv.provider_id
|
16
|
+
AND matrix.verification_id = lv.latest_verification_id
|
17
|
+
|
18
|
+
UNION ALL
|
19
|
+
|
20
|
+
SELECT matrix.*, hpp.tag_name as consumer_version_tag_name
|
21
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
22
|
+
INNER JOIN head_pact_publications hpp
|
23
|
+
ON matrix.consumer_id = hpp.consumer_id
|
24
|
+
AND matrix.provider_id = hpp.provider_id
|
25
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
26
|
+
where verification_id is null
|
27
|
+
"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
down do
|
32
|
+
drop_view(:head_matrix)
|
33
|
+
create_view(:head_matrix,
|
34
|
+
"SELECT matrix.*, hpp.tag_name as consumer_version_tag_name
|
35
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
36
|
+
INNER JOIN head_pact_publications hpp
|
37
|
+
ON matrix.consumer_id = hpp.consumer_id
|
38
|
+
AND matrix.provider_id = hpp.provider_id
|
39
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
40
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider AS lv
|
41
|
+
ON matrix.consumer_version_id = lv.consumer_version_id
|
42
|
+
AND matrix.provider_id = lv.provider_id
|
43
|
+
AND matrix.verification_id = lv.latest_verification_id
|
44
|
+
|
45
|
+
UNION
|
46
|
+
|
47
|
+
SELECT matrix.*, hpp.tag_name as consumer_version_tag_name
|
48
|
+
FROM latest_matrix_for_consumer_version_and_provider_version matrix
|
49
|
+
INNER JOIN head_pact_publications hpp
|
50
|
+
ON matrix.consumer_id = hpp.consumer_id
|
51
|
+
AND matrix.provider_id = hpp.provider_id
|
52
|
+
AND matrix.consumer_version_order = hpp.consumer_version_order
|
53
|
+
where verification_id is null
|
54
|
+
"
|
55
|
+
)
|
56
|
+
|
57
|
+
from(:materialized_head_matrix).delete
|
58
|
+
from(:materialized_head_matrix).insert(from(:head_matrix).select_all)
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# Removes 'overwritten' pacts and verifications from the matrix
|
4
|
+
# (ie. only show latest pact revision for each consumer version and
|
5
|
+
# latest verification for each provider version)
|
6
|
+
# Must include lines where verification_id is null so that we don't
|
7
|
+
# lose the unverified pacts.
|
8
|
+
# In this view there will be one row for each consumer version/provider version
|
9
|
+
# This view used to be (stupidly) called latest_matrix
|
10
|
+
|
11
|
+
# Copied the wrong definition here, forgot about the join to latest_pact_publication_revision_numbers
|
12
|
+
# fixed in 20180210_fix_latest_matrix_for_cv_and_pv_again.rb
|
13
|
+
create_or_replace_view(:latest_matrix_for_consumer_version_and_provider_version,
|
14
|
+
"SELECT matrix.* FROM matrix
|
15
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider_version AS lv
|
16
|
+
ON ((matrix.consumer_version_id = lv.consumer_version_id)
|
17
|
+
AND (matrix.provider_version_id = lv.provider_version_id)
|
18
|
+
AND ((matrix.verification_id = lv.latest_verification_id)))
|
19
|
+
|
20
|
+
UNION ALL
|
21
|
+
|
22
|
+
select matrix.* from matrix
|
23
|
+
inner join latest_pact_publication_revision_numbers lr
|
24
|
+
on matrix.consumer_id = lr.consumer_id
|
25
|
+
and matrix.provider_id = lr.provider_id
|
26
|
+
and matrix.consumer_version_order = lr.consumer_version_order
|
27
|
+
and matrix.pact_revision_number = lr.latest_revision_number
|
28
|
+
where verification_id is null
|
29
|
+
"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
down do
|
34
|
+
# revert to previous crappy definition
|
35
|
+
create_or_replace_view(:latest_matrix_for_consumer_version_and_provider_version,
|
36
|
+
"SELECT matrix.* FROM matrix
|
37
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider_version AS lv
|
38
|
+
ON ((matrix.consumer_version_id = lv.consumer_version_id)
|
39
|
+
AND (matrix.provider_version_id = lv.provider_version_id)
|
40
|
+
AND ((matrix.verification_id = lv.latest_verification_id)))
|
41
|
+
|
42
|
+
UNION
|
43
|
+
|
44
|
+
select matrix.* from matrix
|
45
|
+
inner join latest_pact_publication_revision_numbers lr
|
46
|
+
on matrix.consumer_id = lr.consumer_id
|
47
|
+
and matrix.provider_id = lr.provider_id
|
48
|
+
and matrix.consumer_version_order = lr.consumer_version_order
|
49
|
+
and matrix.pact_revision_number = lr.latest_revision_number
|
50
|
+
where verification_id is null
|
51
|
+
"
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# In this view there will be one row for each consumer version/provider version
|
4
|
+
# Removes 'overwritten' pacts and verifications from the full matrix
|
5
|
+
# (ie. only show latest pact revision for each consumer version and
|
6
|
+
# latest verification for each provider version)
|
7
|
+
# Must include lines where verification_id is null so that we don't
|
8
|
+
# lose the unverified pacts.
|
9
|
+
# This view used to be (stupidly) called latest_matrix
|
10
|
+
|
11
|
+
# Fix mistakenly copied definition in 20180209_recreate_latest_matrix_for_cv_and_pv_union_all.rb
|
12
|
+
# which missed the join to latest_pact_publication_revision_numbers.
|
13
|
+
|
14
|
+
# Change this view to be based on materialized_matrix instead of matrix
|
15
|
+
# to speed it up.
|
16
|
+
# Note! This does mean there is a dependency on having updated
|
17
|
+
# materialized_matrix FIRST that may cause problems. Will see how it goes.
|
18
|
+
|
19
|
+
alter_table(:materialized_matrix) do
|
20
|
+
add_index [:verification_id], name: 'ndx_mm_verif_id'
|
21
|
+
add_index [:pact_revision_number], name: 'ndx_mm_pact_rev_num'
|
22
|
+
end
|
23
|
+
|
24
|
+
create_or_replace_view(:latest_matrix_for_consumer_version_and_provider_version,
|
25
|
+
"SELECT matrix.* FROM materialized_matrix matrix
|
26
|
+
inner join latest_pact_publication_revision_numbers lr
|
27
|
+
on matrix.consumer_id = lr.consumer_id
|
28
|
+
and matrix.provider_id = lr.provider_id
|
29
|
+
and matrix.consumer_version_order = lr.consumer_version_order
|
30
|
+
and matrix.pact_revision_number = lr.latest_revision_number
|
31
|
+
INNER JOIN latest_verification_id_for_consumer_version_and_provider_version AS lv
|
32
|
+
ON ((matrix.consumer_version_id = lv.consumer_version_id)
|
33
|
+
AND (matrix.provider_version_id = lv.provider_version_id)
|
34
|
+
AND ((matrix.verification_id = lv.latest_verification_id)))
|
35
|
+
|
36
|
+
UNION ALL
|
37
|
+
|
38
|
+
select matrix.* from materialized_matrix matrix
|
39
|
+
inner join latest_pact_publication_revision_numbers lr
|
40
|
+
on matrix.consumer_id = lr.consumer_id
|
41
|
+
and matrix.provider_id = lr.provider_id
|
42
|
+
and matrix.consumer_version_order = lr.consumer_version_order
|
43
|
+
and matrix.pact_revision_number = lr.latest_revision_number
|
44
|
+
where verification_id is null
|
45
|
+
"
|
46
|
+
)
|
47
|
+
from(:materialized_head_matrix).delete
|
48
|
+
from(:materialized_head_matrix).insert(from(:head_matrix).select_all)
|
49
|
+
end
|
50
|
+
|
51
|
+
down do
|
52
|
+
end
|
53
|
+
end
|
Binary file
|