Skip to content

Commit

Permalink
fix: Fix metadata endpoint if collection has no matching rows
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed May 23, 2024
1 parent f5ee973 commit 5d67982
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions process/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,29 @@ def metadata(self, request, pk=None):
SELECT
data ->> 'license' AS license,
data ->> 'publicationPolicy' AS publication_policy
FROM
package_data
LEFT JOIN record ON package_data.id = record.package_data_id
AND record.collection_id = %(collection_id)s
LEFT JOIN release ON package_data.id = release.package_data_id
AND release.collection_id = %(collection_id)s
LIMIT 1
FROM (
(
SELECT
data
FROM
package_data
JOIN record ON package_data_id = package_data.id
WHERE
collection_id = %(collection_id)s
LIMIT 1
)
UNION ALL
(
SELECT
data
FROM
package_data
JOIN release ON package_data_id = package_data.id
WHERE
collection_id = %(collection_id)s
LIMIT 1
)
) t
""",
{"collection_id": collection.id},
)
Expand Down

0 comments on commit 5d67982

Please sign in to comment.