Skip to content
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

[FOIMOD-3104] Requests Queues Bug Fix #5249

Merged
merged 2 commits into from
Jun 5, 2024
Merged

[FOIMOD-3104] Requests Queues Bug Fix #5249

merged 2 commits into from
Jun 5, 2024

Conversation

JieunSon96
Copy link
Collaborator

@JieunSon96 JieunSon96 commented Jun 4, 2024

FOIMOD-3104

  • This query utilizes a subquery to select distinct records based on foiministryrequest_id, grouping by foiministryrequestversion_id. It then returns the maximum outcomeid if all outcomeid values are non-null; otherwise, it returns null. This ensures that we capture unique records while accurately reflecting the status of the outcomeid field.

@JieunSon96 JieunSon96 self-assigned this Jun 4, 2024
@JieunSon96 JieunSon96 changed the base branch from test-marshal to dev June 5, 2024 19:53
Copy link
Collaborator

@richard-aot richard-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you want to get requests whose outcomeid ever appears null value. If that's the case, is it possible to just query outcomeid is null in the subquery, instead compare count(outcomeid) = count(*)? That might be more efficient.

@JieunSon96
Copy link
Collaborator Author

Looks like you want to get requests whose outcomeid ever appears null value. If that's the case, is it possible to just query outcomeid is null in the subquery, instead compare count(outcomeid) = count(*)? That might be more efficient.

Yes I also agree for more efficiency I also think it is better to remove the count function because it needs more computations all over records so changed simply checking for NULL and selecting the maximum value instead.

SELECT DISTINCT ON (foiministryrequest_id) foiministryrequest_id, foiministryrequestversion_id, CASE WHEN EXISTS (SELECT 1 FROM "FOIRequestOIPC" WHERE fo.foiministryrequest_id = foiministryrequest_id AND fo.foiministryrequestversion_id = foiministryrequestversion_id AND outcomeid IS NULL) THEN NULL ELSE MAX(outcomeid) END AS outcomeid FROM "FOIRequestOIPC" fo GROUP BY foiministryrequest_id, foiministryrequestversion_id ORDER BY foiministryrequest_id, foiministryrequestversion_id DESC;

Copy link

sonarqubecloud bot commented Jun 5, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@JieunSon96 JieunSon96 merged commit b34d183 into dev Jun 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants