From f169e5715a6a7c01759832eb4f2f98c650cf4fce Mon Sep 17 00:00:00 2001 From: Kyle Lawlor-Bagcal Date: Thu, 31 Aug 2023 18:59:24 -0400 Subject: [PATCH 1/3] chore: comment about votes_by_proposal --- index_votes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index_votes.py b/index_votes.py index 58cc264..caa36ea 100644 --- a/index_votes.py +++ b/index_votes.py @@ -13,6 +13,11 @@ def fetch_votes_by_proposal(height, proposal_id): headers = {"x-cosmos-block-height": str(height)} else: headers = None + # Currently EventVote only contains proposal id + # Eventually EventVote may contain proposal id and voter address + # At which point we could get the vote with this endpoint: + # /cosmos/group/v1/vote_by_proposal_voter/{proposal_id}/{voter} + # Ref: https://github.com/regen-network/indexer/pull/38#discussion_r1310958235 resp = requests.get( f"{os.environ['REGEN_API']}/cosmos/group/v1/votes_by_proposal/{proposal_id}", headers=headers, From 2e1cb8aab258b441dd338650d8e0d455e21aae7d Mon Sep 17 00:00:00 2001 From: Kyle Lawlor-Bagcal Date: Thu, 31 Aug 2023 19:00:51 -0400 Subject: [PATCH 2/3] fix: add V1_12__votes.sql to migrations script --- sql/run_all_migrations.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/run_all_migrations.sh b/sql/run_all_migrations.sh index c0665ca..ab9d2a5 100755 --- a/sql/run_all_migrations.sh +++ b/sql/run_all_migrations.sh @@ -15,3 +15,4 @@ psql -c "\i V1_8__index_proposal_id.sql" $DATABASE_URL psql -c "\i V1_9__all_ecocredit_txes.sql" $DATABASE_URL psql -c "\i V1_10__class_issuers.sql" $DATABASE_URL psql -c "\i V1_11__class_issuers_indexes.sql" $DATABASE_URL +psql -c "\i V1_12__votes.sql" $DATABASE_URL From af2fcd9ee7c0d86af52103fd14c36e55c831937a Mon Sep 17 00:00:00 2001 From: Kyle Lawlor-Bagcal Date: Thu, 31 Aug 2023 19:06:29 -0400 Subject: [PATCH 3/3] fix: break from votes loop if proposal is not yet pruned --- index_votes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index_votes.py b/index_votes.py index caa36ea..c2d97e1 100644 --- a/index_votes.py +++ b/index_votes.py @@ -117,6 +117,8 @@ def _index_votes(pg_conn, _client, _chain_num): except ForeignKeyViolation as exc: logger.debug(exc) pg_conn.rollback() + # since we know all votes for this proposal will fail we exit the loop + break def index_votes():