Skip to content

Commit cace1a5

Browse files
authored
Fix tech review query routes (#4946)
1 parent 803c17d commit cace1a5

9 files changed

+73
-155
lines changed

apps/labrinth/.sqlx/query-112bc4904c32afc9ffba30528a9c0e7b7fe259c58411afa5ef86a7ae4bde2703.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/.sqlx/query-3240e4b5abc9850b5d3c09fafcac71674941487c15be1e8ce0ebc78e7c26b34d.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/labrinth/.sqlx/query-3961aa17ce3219c057c398dca0ed3aaeb30a8da4721959fdee99cf649a8b29e3.json

Lines changed: 0 additions & 49 deletions
This file was deleted.

apps/labrinth/.sqlx/query-3e2804a3443239104b2d8b095941fe1472402338e0f0bb323b6147d2a0cc4eca.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

apps/labrinth/.sqlx/query-6cf1862b3c197d42f9183dcbbd3d07b7d42c37e089403961ee16be0f99958ea0.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/labrinth/.sqlx/query-7d1f49699e242f3e002afee9bf466b6696052ac6d5ebe131b9e7242104f700af.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

apps/labrinth/.sqlx/query-8820a5985291c159c98371c9650092e3eba21c81e3b3386be779978aff30451a.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/.sqlx/query-b1df83f4592701f8aa03f6d16bac9e2bd27ac9a87987eafd79b06f1c4ecdb659.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

apps/labrinth/src/routes/internal/moderation/tech_review.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,20 @@ async fn get_issue(
191191
|| jsonb_build_object(
192192
-- TODO: replace with `json_array` in Postgres 16
193193
'details', (
194-
SELECT json_agg(to_jsonb(drid))
195-
FROM delphi_report_issue_details drid
196-
WHERE drid.issue_id = dri.id
194+
SELECT coalesce(jsonb_agg(
195+
jsonb_build_object(
196+
'id', didws.id,
197+
'issue_id', didws.issue_id,
198+
'key', didws.key,
199+
'file_path', didws.file_path,
200+
'decompiled_source', didws.decompiled_source,
201+
'data', didws.data,
202+
'severity', didws.severity,
203+
'status', didws.status
204+
)
205+
), '[]'::jsonb)
206+
FROM delphi_issue_details_with_statuses didws
207+
WHERE didws.issue_id = dri.id
197208
)
198209
) AS "data!: sqlx::types::Json<FileIssue>"
199210
FROM delphi_report_issues dri
@@ -238,6 +249,7 @@ async fn get_report(
238249
SELECT DISTINCT ON (dr.id)
239250
to_jsonb(dr)
240251
|| jsonb_build_object(
252+
'report_id', dr.id,
241253
'file_id', to_base62(f.id),
242254
'version_id', to_base62(v.id),
243255
'project_id', to_base62(v.mod_id),
@@ -252,9 +264,20 @@ async fn get_report(
252264
|| jsonb_build_object(
253265
-- TODO: replace with `json_array` in Postgres 16
254266
'details', (
255-
SELECT json_agg(to_jsonb(drid))
256-
FROM delphi_report_issue_details drid
257-
WHERE drid.issue_id = dri.id
267+
SELECT coalesce(jsonb_agg(
268+
jsonb_build_object(
269+
'id', didws.id,
270+
'issue_id', didws.issue_id,
271+
'key', didws.key,
272+
'file_path', didws.file_path,
273+
'decompiled_source', didws.decompiled_source,
274+
'data', didws.data,
275+
'severity', didws.severity,
276+
'status', didws.status
277+
)
278+
), '[]'::jsonb)
279+
FROM delphi_issue_details_with_statuses didws
280+
WHERE didws.issue_id = dri.id
258281
)
259282
)
260283
)

0 commit comments

Comments
 (0)