Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unhandled exception when member hash is not correct #2996

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ EnrichedCurrentMembers AS (
) AS enriched_members
FROM
ProcessedCurrentMembers pcm
LEFT JOIN
json_array_elements(pcm.current_members) AS member ON true
LEFT JOIN
CommitteeData cm ON cm.hash = encode(decode(member->>'hash', 'hex'), 'hex')
LEFT JOIN json_array_elements(pcm.current_members) AS member ON true
LEFT JOIN CommitteeData cm
ON (CASE
WHEN (member->>'hash') ~ '^[0-9a-fA-F]+$'
THEN encode(decode(member->>'hash', 'hex'), 'hex')
ELSE NULL
END) = cm.hash
GROUP BY
pcm.id
),
Expand Down Expand Up @@ -199,7 +202,13 @@ SELECT
'tag', pd.tag,
'members', em.enriched_members,
'membersToBeRemoved', mtr.members_to_be_removed,
'threshold', pd.threshold::float
'threshold',
CASE
WHEN (pd.threshold->>'numerator') IS NOT NULL
AND (pd.threshold->>'denominator') IS NOT NULL
THEN (pd.threshold->>'numerator')::float / (pd.threshold->>'denominator')::float
ELSE NULL
END
)
FROM
ParsedDescription pd
Expand Down