diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b8b9516a..e0acd8913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Changes #### Gov module - ([\#401](https://github.com/forbole/bdjuno/pull/401)) Update the proposal status to the latest in `bdjuno parse gov proposal [id]` command +- ([\#430](https://github.com/forbole/bdjuno/pull/430)) Update the proposals that have invalid status but can still be in voting or deposit periods ### Dependencies - ([\#412](https://github.com/forbole/bdjuno/pull/412)) Updated Juno to `v3.2.1` diff --git a/database/gov.go b/database/gov.go index f63de9e77..26de439f2 100644 --- a/database/gov.go +++ b/database/gov.go @@ -209,6 +209,16 @@ func (db *Db) GetOpenProposalsIds() ([]uint64, error) { var ids []uint64 stmt := `SELECT id FROM proposal WHERE status = $1 OR status = $2` err := db.Sqlx.Select(&ids, stmt, govtypes.StatusDepositPeriod.String(), govtypes.StatusVotingPeriod.String()) + if err != nil { + return ids, err + } + + // Get also the invalid status proposals due to gRPC failure but still are in deposit period or voting period + var idsInvalid []uint64 + stmt = `SELECT id FROM proposal WHERE status = $1 AND (voting_end_time > NOW() OR deposit_end_time > NOW())` + err = db.Sqlx.Select(&idsInvalid, stmt, types.ProposalStatusInvalid) + ids = append(ids, idsInvalid...) + return ids, err }