Skip to content

Commit

Permalink
feat: update proposals that have invalid status but can still be in v…
Browse files Browse the repository at this point in the history
…oting or deposit periods (#430)

## Description

Closes: #XXXX



---
The proposals in voting period are often marked as `PROPOSAL_STATUS_INVALID` because of not found on chain probably due to gRPC failure. It results in the proposal never gets updated given its invalid status. 

Now the proposals will be updated until the `deposit_end_time` or `voting_end_time` even if the proposal status is invalid.  

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
huichiaotsou authored Jul 6, 2022
1 parent f9eaebd commit 49e3089
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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

0 comments on commit 49e3089

Please sign in to comment.