Skip to content

Commit

Permalink
Fix sql query for combining raw and ministry correspondences
Browse files Browse the repository at this point in the history
  • Loading branch information
milosdes committed Aug 20, 2024
1 parent e59536f commit a126f5e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ def getapplicantcorrespondencesrawrequests(cls, requestid):
created_at, createdby, sentcorrespondencemessage, parentapplicantcorrespondenceid, sentby, sent_at,
isdraft, isdeleted, isresponse, response_at
from "FOIApplicantCorrespondencesRawRequests" rawcorr
where foirawrequest_id = :requestid
where foirawrequest_id = (
SELECT foirawrequestid FROM public."FOIRequests"
WHERE foirequestid = :requestid
ORDER BY foirequestid ASC, version DESC limit 1)
OR
foirawrequest_id = :requestid
order by applicantcorrespondenceid desc, version desc"""
rs = db.session.execute(text(sql), {'requestid': requestid})
for row in rs:
Expand Down

0 comments on commit a126f5e

Please sign in to comment.