Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1241 from weichang-bianjie/develop
Browse files Browse the repository at this point in the history
R4R:fix the code for update the proposal info
  • Loading branch information
zhangjinbiao746 authored Dec 13, 2019
2 parents 0fbc7c3 + 72c2798 commit a321897
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion backend/orm/document/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (_ Proposal) QueryIdTitleStatusVotedTxhashByValidatorAcc(validatorAcc strin
return cnt, data, err
}

func (_ Proposal) GetProposalsByStatus(status, sorts []string) ([]Proposal, error) {
func (_ Proposal) GetProposalsByStatus(status, sorts []string, is_selecter bool) ([]Proposal, error) {
var (
proposals []Proposal
query = orm.NewQuery()
Expand All @@ -236,6 +236,9 @@ func (_ Proposal) GetProposalsByStatus(status, sorts []string) ([]Proposal, erro
Proposal_Field_TotalDeposit: 1,
Proposal_Field_DepositEndTime: 1,
}
if !is_selecter {
selector = bson.M{}
}

condition := bson.M{
"status": bson.M{
Expand Down
4 changes: 2 additions & 2 deletions backend/service/service_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (service *ProposalService) QueryDepositAndVotingProposalList(needMoniker bo
status := []string{document.ProposalStatusDeposit, document.ProposalStatusVoting}
sorts := []string{document.Proposal_Field_VotingEndTime, document.Proposal_Field_DepositEndTime}

data, err := proposalDocument.GetProposalsByStatus(status, sorts)
data, err := proposalDocument.GetProposalsByStatus(status, sorts, true)
if err != nil {
logger.Error("query proposal collection", logger.String("err", err.Error()))
return nil
Expand Down Expand Up @@ -739,7 +739,7 @@ func (service *ProposalService) Query(id int) (resp vo.ProposalInfoVo) {

isRejectVote := false
if votedNum > 0 {
isRejectVote = bool(isParticipation && bool((noWithVeto/votedNum) > vetoThresholdFloat))
isRejectVote = bool(isParticipation && bool((noWithVeto / votedNum) > vetoThresholdFloat))
}
burnPercent, err := lcd.GetProposalBurnPercentByResult(data.Status, isRejectVote)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions backend/service/service_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"encoding/json"
"github.com/irisnet/explorer/backend/logger"
"github.com/irisnet/explorer/backend/utils"
"github.com/irisnet/explorer/backend/orm/document"
)

func TestGetDelegationsFromLcd(t *testing.T) {
Expand Down Expand Up @@ -91,6 +92,16 @@ func TestValidatorService_UpdateValidatorStaticData(t *testing.T) {
t.Log("success")
}
}
func TestValidatorService_UpdateValidators(t *testing.T) {

validators, _ := document.Validator{}.GetAllValidator()
//fmt.Println(validators)
if err := validatorService.UpdateValidators(validators); err != nil {
t.Fatal(err)
} else {
t.Log("success")
}
}

func TestBuildValidators(t *testing.T) {
res := buildValidators()
Expand Down
2 changes: 1 addition & 1 deletion backend/task/update_proposal_voters.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (task UpdateProposalVoters) Start() {
func (task UpdateProposalVoters) DoTask() error {
status := []string{document.ProposalStatusVoting}
sorts := []string{document.Proposal_Field_VotingEndTime}
proposals, err := document.Proposal{}.GetProposalsByStatus(status, sorts)
proposals, err := document.Proposal{}.GetProposalsByStatus(status, sorts, false)
if err != nil {
return err
}
Expand Down

0 comments on commit a321897

Please sign in to comment.