Skip to content

Commit

Permalink
Merge pull request #5249 from bcgov/foimod-3104-test
Browse files Browse the repository at this point in the history
[FOIMOD-3104] Requests Queues Bug Fix
  • Loading branch information
JieunSon96 authored Jun 5, 2024
2 parents 7a4436f + 8af383b commit b34d183
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions request-management-api/request_api/models/FOIMinistryRequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,12 @@ def getrequestssubquery(cls, groups, filterfields, keyword, additionalfilter, us

#subquery for getting extension count
subquery_extension_count = _session.query(FOIRequestExtension.foiministryrequest_id, func.count(distinct(FOIRequestExtension.foirequestextensionid)).filter(FOIRequestExtension.isactive == True).label('extensions')).group_by(FOIRequestExtension.foiministryrequest_id).subquery()

#subquery for getting all, distinct oipcs for foiministry request
#subquery for selecting distinct records based on foiministryrequest_id, grouping by foiministryrequestversion_id
subquery_with_oipc_sql = """
SELECT distinct on (foiministryrequest_id) foiministryrequest_id, foiministryrequestversion_id, outcomeid
FROM "FOIRequestOIPC" fo
order by foiministryrequest_id, foiministryrequestversion_id desc
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
"""
subquery_with_oipc = text(subquery_with_oipc_sql).columns(FOIRequestOIPC.foiministryrequest_id, FOIRequestOIPC.foiministryrequestversion_id, FOIRequestOIPC.outcomeid).alias("oipcnoneoutcomes")
joincondition_oipc = [
Expand Down Expand Up @@ -662,7 +662,7 @@ def getrequestssubquery(cls, groups, filterfields, keyword, additionalfilter, us
),
isouter=True
).filter(or_(FOIMinistryRequest.requeststatuslabel != StateName.closed.name,
and_(FOIMinistryRequest.isoipcreview == True, FOIMinistryRequest.requeststatusid == 3)))
and_(FOIMinistryRequest.isoipcreview == True, FOIMinistryRequest.requeststatusid == 3,subquery_with_oipc.c.outcomeid == None)))



Expand Down

0 comments on commit b34d183

Please sign in to comment.