decidim-vocdoni / decidim-module-vocdoni

(WIP) A module for Decidim that brings an elections component based on the Vocdoni SDK and API
GNU Affero General Public License v3.0
8 stars 0 forks source link

Update vocdoni/sdk 0.0.15 #64

Closed antopalidi closed 1 year ago

antopalidi commented 1 year ago

The new version of Vocdoni 0.0.15 adds a new function calculateElectionCost:

  public calculateElectionCost(election: UnpublishedElection): Promise<number> {
    return this.fetchChainId()
      .then(() =>
        ElectionAPI.price(
          this.url,
          election.maxCensusSize,
          ElectionCore.estimateElectionBlocks(election, this.chainData),
          election.electionType.secretUntilTheEnd,
          election.electionType.anonymous,
          election.voteType.maxVoteOverwrites
        )
      )
      .then((cost) => cost.price);
  }

It was necessary to change the value of the constant MAX_VOTE_OVERWRITES from -1 to 0 to calculate the cost correctly

codecov[bot] commented 1 year ago

Codecov Report

Merging #64 (850f6c3) into main (49275b1) will increase coverage by 5.31%. The diff coverage is 97.50%.

:exclamation: Current head 850f6c3 differs from pull request most recent head 499624b. Consider uploading reports for the commit 499624b to get more accurate results

@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
+ Coverage   86.78%   92.09%   +5.31%     
==========================================
  Files          80       84       +4     
  Lines        1506     1582      +76     
==========================================
+ Hits         1307     1457     +150     
+ Misses        199      125      -74     
Impacted Files Coverage Δ
.../commands/decidim/vocdoni/admin/create_election.rb 100.00% <ø> (ø)
.../commands/decidim/vocdoni/admin/update_election.rb 100.00% <ø> (ø)
app/forms/decidim/vocdoni/admin/election_form.rb 100.00% <ø> (ø)
...lers/decidim/vocdoni/admin/elections_controller.rb 81.53% <83.33%> (+29.15%) :arrow_up:
...idim/vocdoni/admin/election_calendar_controller.rb 90.00% <90.00%> (ø)
.../decidim/vocdoni/admin/update_election_calendar.rb 100.00% <100.00%> (ø)
...rs/decidim/vocdoni/admin/application_controller.rb 90.90% <100.00%> (+0.90%) :arrow_up:
...rollers/decidim/vocdoni/admin/census_controller.rb 95.65% <100.00%> (ø)
...ms/decidim/vocdoni/admin/election_calendar_form.rb 100.00% <100.00%> (ø)
app/forms/decidim/vocdoni/admin/setup_form.rb 100.00% <100.00%> (ø)
... and 5 more

... and 3 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

antopalidi commented 1 year ago

@andreslucena this pr is ready for review

antopalidi commented 1 year ago

@andreslucena

Yes, I know this will be implemented and improved later. So for now I suggested to set MAX_VOTE_OVERWRITES = 0 to avoid test errors when creating elections, because this parameter cannot be -1

Changes added