From 0c764e25824f0bba60fdaba38dfaf140d540c643 Mon Sep 17 00:00:00 2001 From: domi41 Date: Wed, 7 Jul 2021 18:10:52 +0200 Subject: [PATCH] refacto: move the DeliberatorInterface around --- deliberator.go | 5 +++++ majorityjudgment.go | 17 ----------------- 2 files changed, 5 insertions(+), 17 deletions(-) create mode 100644 deliberator.go diff --git a/deliberator.go b/deliberator.go new file mode 100644 index 0000000..4ad941e --- /dev/null +++ b/deliberator.go @@ -0,0 +1,5 @@ +package judgment + +type DeliberatorInterface interface { + Deliberate(tally *PollTally) (result *PollResult, err error) +} diff --git a/majorityjudgment.go b/majorityjudgment.go index 031432c..6897db0 100644 --- a/majorityjudgment.go +++ b/majorityjudgment.go @@ -5,28 +5,12 @@ import ( "sort" ) -type DeliberatorInterface interface { - Deliberate(tally *PollTally) (result *PollResult, err error) -} - type MajorityJudgment struct { favorContestation bool // strategy for evenness of judgments ; defaults to true } func (mj *MajorityJudgment) Deliberate(tally *PollTally) (_ *PollResult, err error) { - // TODO: preset balancers : static, median, normalization - //// Consider missing judgments as TO_REJECT judgments - //// One reason why we need many algorithms, and options on each - //for _, candidateTally := range pollTally.Candidates { - // missing := pollTally.MaxJudgmentsAmount - candidateTally.JudgmentsAmount - // if 0 < missing { - // candidateTally.JudgmentsAmount = pollTally.MaxJudgmentsAmount - // candidateTally.Grades[0].Amount += missing - // //println("Added the missing TO REJECT judgments", missing) - // } - //} - amountOfProposals := len(tally.Proposals) if 0 == amountOfProposals { return &PollResult{Proposals: []*ProposalResult{}}, nil @@ -56,7 +40,6 @@ func (mj *MajorityJudgment) Deliberate(tally *PollTally) (_ *PollResult, err err "perhaps you forgot to set PollTally.AmountOfJudges") } - //amountOfJudgments := tally.Proposals[0].CountJudgments() for proposalIndex, proposalTally := range tally.Proposals { if amountOfJudges != proposalTally.CountJudgments() { return nil, fmt.Errorf("unbalanced tally: "+