Skip to content

Commit 7732713

Browse files
authored
Merge pull request #2163 from IntersectMBO/staging
fix(#2125): fix counting Governance Action expiration
2 parents de79f2b + d0d14b1 commit 7732713

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

govtool/backend/sql/list-proposals.sql

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ WITH LatestDrepDistr AS (
55
FROM
66
drep_distr
77
),
8-
EpochUtils AS (
8+
LatestEpoch AS (
99
SELECT
10-
(Max(end_time) - Min(end_time)) /(Max(NO) - Min(NO)) AS epoch_duration,
11-
Max(NO) AS last_epoch_no,
12-
Max(end_time) AS last_epoch_end_time
10+
start_time,
11+
no
1312
FROM
14-
epoch
13+
epoch ORDER BY no DESC LIMIT 1
1514
),
1615
always_no_confidence_voting_power AS (
1716
SELECT
@@ -56,13 +55,9 @@ SELECT
5655
) as description,
5756
CASE
5857
WHEN meta.network_name::text = 'mainnet' THEN
59-
epoch_utils.last_epoch_end_time +
60-
epoch_utils.epoch_duration * (gov_action_proposal.expiration - epoch_utils.last_epoch_no)::bigint +
61-
INTERVAL '5 days'
58+
latest_epoch.start_time + (gov_action_proposal.expiration - latest_epoch.no)::bigint * INTERVAL '5 days' + INTERVAL '5 days'
6259
ELSE
63-
epoch_utils.last_epoch_end_time +
64-
epoch_utils.epoch_duration * (gov_action_proposal.expiration - epoch_utils.last_epoch_no)::bigint +
65-
INTERVAL '1 day'
60+
latest_epoch.start_time + (gov_action_proposal.expiration - latest_epoch.no)::bigint * INTERVAL '1 day' + INTERVAL '1 day'
6661
END AS expiry_date,
6762
gov_action_proposal.expiration,
6863
creator_block.time,
@@ -101,7 +96,7 @@ FROM
10196
on gov_action_proposal.id = treasury_withdrawal.gov_action_proposal_id
10297
LEFT JOIN stake_address
10398
on stake_address.id = treasury_withdrawal.stake_address_id
104-
CROSS JOIN EpochUtils AS epoch_utils
99+
CROSS JOIN LatestEpoch AS latest_epoch
105100
CROSS JOIN always_no_confidence_voting_power
106101
CROSS JOIN always_abstain_voting_power
107102
CROSS JOIN meta
@@ -162,9 +157,8 @@ GROUP BY
162157
gov_action_proposal.index,
163158
creator_tx.hash,
164159
creator_block.time,
165-
epoch_utils.epoch_duration,
166-
epoch_utils.last_epoch_no,
167-
epoch_utils.last_epoch_end_time,
160+
latest_epoch.start_time,
161+
latest_epoch.no,
168162
proposal_params,
169163
voting_anchor.url,
170164
voting_anchor.data_hash,

0 commit comments

Comments
 (0)