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

feat: update proposals that have invalid status but can still be in voting or deposit periods #430

Merged
merged 2 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
10 changes: 10 additions & 0 deletions database/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down