Skip to content

Commit 0d7b44b

Browse files
committed
(fix) Hotfix for duplicated entries for pools for epoch 568 on mainnet in pool_stat table
1 parent 9f69308 commit 0d7b44b

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

govtool/backend/sql/list-proposals.sql

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
WITH ActiveProposals AS (
2-
SELECT id
2+
SELECT id
33
FROM gov_action_proposal
44
WHERE expiration > (SELECT MAX(no) FROM epoch)
55
AND ratified_epoch IS NULL
@@ -97,11 +97,11 @@ EnrichedCurrentMembers AS (
9797
FROM
9898
ProcessedCurrentMembers pcm
9999
LEFT JOIN json_array_elements(pcm.current_members) AS member ON true
100-
LEFT JOIN CommitteeData cm
101-
ON (CASE
102-
WHEN (member->>'hash') ~ '^[0-9a-fA-F]+$'
103-
THEN encode(decode(member->>'hash', 'hex'), 'hex')
104-
ELSE NULL
100+
LEFT JOIN CommitteeData cm
101+
ON (CASE
102+
WHEN (member->>'hash') ~ '^[0-9a-fA-F]+$'
103+
THEN encode(decode(member->>'hash', 'hex'), 'hex')
104+
ELSE NULL
105105
END) = cm.hash
106106
GROUP BY
107107
pcm.id
@@ -155,29 +155,29 @@ RankedDRepVotes AS (
155155
vp.gov_action_proposal_id,
156156
vp.drep_voter,
157157
vp.vote
158-
FROM
158+
FROM
159159
voting_procedure vp
160-
WHERE
160+
WHERE
161161
vp.drep_voter IS NOT NULL
162162
AND vp.gov_action_proposal_id IN (SELECT id FROM ActiveProposals)
163-
ORDER BY
164-
vp.drep_voter,
165-
vp.gov_action_proposal_id,
163+
ORDER BY
164+
vp.drep_voter,
165+
vp.gov_action_proposal_id,
166166
vp.tx_id DESC,
167167
vp.id DESC
168168
),
169169
RankedDRepRegistration AS (
170170
SELECT DISTINCT ON (dr.drep_hash_id)
171171
dr.*
172-
FROM
172+
FROM
173173
drep_registration dr
174-
ORDER BY
174+
ORDER BY
175175
dr.drep_hash_id,
176176
dr.tx_id DESC,
177177
dr.id DESC
178178
),
179179
CommitteeVotes AS (
180-
SELECT
180+
SELECT
181181
vp.gov_action_proposal_id,
182182
SUM(CASE WHEN vp.vote = 'Yes' THEN 1 ELSE 0 END) AS ccYesVotes,
183183
SUM(CASE WHEN vp.vote = 'No' THEN 1 ELSE 0 END) AS ccNoVotes,
@@ -190,13 +190,13 @@ CommitteeVotes AS (
190190
FROM voting_procedure
191191
WHERE committee_voter IS NOT NULL
192192
AND gov_action_proposal_id IN (SELECT id FROM ActiveProposals)
193-
ORDER BY
194-
committee_voter,
195-
gov_action_proposal_id,
193+
ORDER BY
194+
committee_voter,
195+
gov_action_proposal_id,
196196
tx_id DESC,
197197
id DESC
198198
) vp
199-
GROUP BY
199+
GROUP BY
200200
vp.gov_action_proposal_id
201201
)
202202
SELECT
@@ -223,13 +223,13 @@ SELECT
223223

224224
WHEN gov_action_proposal.type::text = 'HardForkInitiation' THEN
225225
json_build_object(
226-
'major', (gov_action_proposal.description->'contents'->1->>'major')::int,
226+
'major', (gov_action_proposal.description->'contents'->1->>'major')::int,
227227
'minor', (gov_action_proposal.description->'contents'->1->>'minor')::int
228228
)
229229

230230
WHEN gov_action_proposal.type::text = 'NoConfidence' THEN
231231
json_build_object('data', gov_action_proposal.description->'contents')
232-
232+
233233
WHEN gov_action_proposal.type::text = 'ParameterChange' THEN
234234
json_build_object('data', gov_action_proposal.description->'contents')
235235

@@ -245,12 +245,12 @@ SELECT
245245
'tag', pd.tag,
246246
'members', em.enriched_members,
247247
'membersToBeRemoved', mtr.members_to_be_removed,
248-
'threshold',
249-
CASE
250-
WHEN (pd.threshold->>'numerator') IS NOT NULL
251-
AND (pd.threshold->>'denominator') IS NOT NULL
248+
'threshold',
249+
CASE
250+
WHEN (pd.threshold->>'numerator') IS NOT NULL
251+
AND (pd.threshold->>'denominator') IS NOT NULL
252252
THEN (pd.threshold->>'numerator')::float / (pd.threshold->>'denominator')::float
253-
ELSE NULL
253+
ELSE NULL
254254
END
255255
)
256256
FROM
@@ -268,9 +268,9 @@ SELECT
268268
, '{}'::JSON) AS description,
269269
CASE
270270
WHEN meta.network_name::text = 'mainnet' OR meta.network_name::text = 'preprod' THEN
271-
latest_epoch.start_time + (gov_action_proposal.expiration - latest_epoch.no)::bigint * INTERVAL '5 days'
271+
latest_epoch.start_time + (gov_action_proposal.expiration - latest_epoch.no)::bigint * INTERVAL '5 days'
272272
ELSE
273-
latest_epoch.start_time + (gov_action_proposal.expiration - latest_epoch.no)::bigint * INTERVAL '1 day'
273+
latest_epoch.start_time + (gov_action_proposal.expiration - latest_epoch.no)::bigint * INTERVAL '1 day'
274274
END AS expiry_date,
275275
gov_action_proposal.expiration,
276276
creator_block.time,
@@ -279,7 +279,7 @@ SELECT
279279
encode(voting_anchor.data_hash, 'hex') data_hash,
280280
jsonb_set(
281281
ROW_TO_JSON(proposal_params)::jsonb,
282-
'{cost_model}',
282+
'{cost_model}',
283283
CASE
284284
WHEN cost_model.id IS NOT NULL THEN
285285
ROW_TO_JSON(cost_model)::jsonb
@@ -347,7 +347,7 @@ FROM
347347
LEFT JOIN LatestDrepDistr ldd_drep ON ldd_drep.hash_id = rdr.drep_hash_id
348348
AND ldd_drep.epoch_no = latest_epoch.no
349349
LEFT JOIN gov_action_proposal AS prev_gov_action ON gov_action_proposal.prev_gov_action_proposal = prev_gov_action.id
350-
LEFT JOIN tx AS prev_gov_action_tx ON prev_gov_action.tx_id = prev_gov_action_tx.id
350+
LEFT JOIN tx AS prev_gov_action_tx ON prev_gov_action.tx_id = prev_gov_action_tx.id
351351
WHERE
352352
(COALESCE(?, '') = '' OR
353353
off_chain_vote_gov_action_data.title ILIKE ? OR

0 commit comments

Comments
 (0)