Skip to content

Commit 183aef6

Browse files
authored
Fix attachments queries (#1041)
1 parent 6bd12ac commit 183aef6

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

api/src/Feature.Form.Submissions/ListEntries/Endpoint.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ form_submissions AS (SELECT fs."Id"
186186
fs."NumberOfFlaggedAnswers",
187187
(SELECT COUNT(1)
188188
FROM "Attachments" A
189-
WHERE A."FormId" = fs."FormId"
190-
AND a."MonitoringObserverId" = fs."MonitoringObserverId"
191-
AND fs."PollingStationId" = A."PollingStationId"
189+
WHERE a."MonitoringObserverId" = FS."MonitoringObserverId"
190+
AND (
191+
(A."FormId" = FS."FormId" AND FS."PollingStationId" = A."PollingStationId") -- backwards compatibility
192+
OR A."SubmissionId" = FS."Id"
193+
)
192194
AND A."IsDeleted" = false
193195
AND A."IsCompleted" = true) AS "MediaFilesCount",
194196
(SELECT COUNT(1)

api/src/Vote.Monitor.Hangfire/Jobs/Export/FormSubmissions/ExportFormSubmissionsJob.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,10 @@ ORDER BY
228228
"Attachments" A
229229
WHERE
230230
A."ElectionRoundId" = @ELECTIONROUNDID
231-
AND A."FormId" = FS."FormId"
232-
AND A."MonitoringObserverId" = FS."MonitoringObserverId"
233-
AND FS."PollingStationId" = A."PollingStationId"
231+
AND (
232+
(A."FormId" = FS."FormId" AND FS."PollingStationId" = A."PollingStationId") -- backwards compatibility
233+
OR A."SubmissionId" = FS."Id"
234+
)
234235
),
235236
'[]'::JSONB
236237
) AS "Attachments",

0 commit comments

Comments
 (0)