-
Notifications
You must be signed in to change notification settings - Fork 3
fix: refresh_mvCountIssueRatingsServiceId_proc #1187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MR2011
merged 2 commits into
main
from
kanstantsinbuklis-sap/issue-1177/fix-refresh-proc
May 5, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
internal/database/mariadb/migrations/20260504154924_change_join_kind.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| -- SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
| -- SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| DROP PROCEDURE IF EXISTS refresh_mvCountIssueRatingsServiceId_proc; | ||
|
|
||
| CREATE PROCEDURE refresh_mvCountIssueRatingsServiceId_proc() | ||
| BEGIN | ||
| UPDATE mvCountIssueRatingsServiceId | ||
| SET is_active = 0 | ||
| WHERE is_active = 1; | ||
|
|
||
| INSERT INTO mvCountIssueRatingsServiceId ( | ||
| service_id, | ||
| service_ccrn, | ||
| critical_count, | ||
| high_count, | ||
| medium_count, | ||
| low_count, | ||
| none_count, | ||
| is_active | ||
| ) | ||
| SELECT | ||
| CI.componentinstance_service_id, | ||
| S.service_ccrn, | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'Critical' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'High' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'Medium' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'Low' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'None' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| 1 | ||
| FROM Issue I | ||
| LEFT JOIN IssueVariant IV ON IV.issuevariant_issue_id = I.issue_id | ||
| LEFT JOIN IssueMatch IM ON I.issue_id = IM.issuematch_issue_id | ||
| LEFT JOIN ComponentInstance CI | ||
| ON CI.componentinstance_id = IM.issuematch_component_instance_id | ||
| AND CI.componentinstance_deleted_at IS NULL | ||
| LEFT JOIN Service S ON S.service_id = CI.componentinstance_service_id | ||
| LEFT JOIN Remediation R | ||
| ON CI.componentinstance_service_id = R.remediation_service_id | ||
| AND I.issue_id = R.remediation_issue_id | ||
| AND R.remediation_deleted_at IS NULL | ||
| WHERE I.issue_deleted_at IS NULL | ||
| AND IM.issuematch_id IS NOT NULL | ||
| AND (R.remediation_id IS NULL OR R.remediation_expiration_date < CURDATE()) | ||
| GROUP BY CI.componentinstance_service_id | ||
| ON DUPLICATE KEY UPDATE | ||
| service_ccrn = VALUES(service_ccrn), | ||
| critical_count = VALUES(critical_count), | ||
| high_count = VALUES(high_count), | ||
| medium_count = VALUES(medium_count), | ||
| low_count = VALUES(low_count), | ||
| none_count = VALUES(none_count), | ||
| is_active = 1; | ||
|
|
||
| DELETE FROM mvCountIssueRatingsServiceId | ||
| WHERE is_active = 0; | ||
| END; |
62 changes: 62 additions & 0 deletions
62
internal/database/mariadb/migrations/20260504154924_change_join_kind.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| -- SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
| -- SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| DROP PROCEDURE IF EXISTS refresh_mvCountIssueRatingsServiceId_proc; | ||
|
|
||
| CREATE PROCEDURE refresh_mvCountIssueRatingsServiceId_proc() | ||
| BEGIN | ||
| UPDATE mvCountIssueRatingsServiceId | ||
| SET is_active = 0 | ||
| WHERE is_active = 1; | ||
|
|
||
| INSERT INTO mvCountIssueRatingsServiceId ( | ||
| service_id, | ||
| service_ccrn, | ||
| critical_count, | ||
| high_count, | ||
| medium_count, | ||
| low_count, | ||
| none_count, | ||
| is_active | ||
| ) | ||
| SELECT | ||
| CI.componentinstance_service_id, | ||
| S.service_ccrn, | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'Critical' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'High' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'Medium' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'Low' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| COUNT(DISTINCT CASE WHEN IV.issuevariant_rating = 'None' | ||
| THEN CONCAT(CI.componentinstance_component_version_id, ',', I.issue_id) END), | ||
| 1 | ||
| FROM Issue I | ||
| LEFT JOIN IssueVariant IV ON IV.issuevariant_issue_id = I.issue_id | ||
| LEFT JOIN IssueMatch IM ON I.issue_id = IM.issuematch_issue_id | ||
| LEFT JOIN ComponentInstance CI | ||
| ON CI.componentinstance_id = IM.issuematch_component_instance_id | ||
| AND CI.componentinstance_deleted_at IS NULL | ||
| JOIN Service S ON S.service_id = CI.componentinstance_service_id | ||
| LEFT JOIN Remediation R | ||
| ON CI.componentinstance_service_id = R.remediation_service_id | ||
| AND I.issue_id = R.remediation_issue_id | ||
| AND R.remediation_deleted_at IS NULL | ||
| WHERE I.issue_deleted_at IS NULL | ||
| AND IM.issuematch_id IS NOT NULL | ||
| AND (R.remediation_id IS NULL OR R.remediation_expiration_date < CURDATE()) | ||
| GROUP BY CI.componentinstance_service_id | ||
| ON DUPLICATE KEY UPDATE | ||
| service_ccrn = VALUES(service_ccrn), | ||
| critical_count = VALUES(critical_count), | ||
| high_count = VALUES(high_count), | ||
| medium_count = VALUES(medium_count), | ||
| low_count = VALUES(low_count), | ||
| none_count = VALUES(none_count), | ||
| is_active = 1; | ||
|
|
||
| DELETE FROM mvCountIssueRatingsServiceId | ||
| WHERE is_active = 0; | ||
| END; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change most probably will corrupt some functionality. We need to keep this goroutine in background otherwise app will not start up until post migration is not done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, checked on the production dump and it takes lots of time, will return this goroutine