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

bug: maxCensusSize is always undefined #235

Closed
elboletaire opened this issue Aug 4, 2023 · 1 comment · Fixed by #236
Closed

bug: maxCensusSize is always undefined #235

elboletaire opened this issue Aug 4, 2023 · 1 comment · Fixed by #236
Labels
bug Something isn't working

Comments

@elboletaire
Copy link
Member

elboletaire commented Aug 4, 2023

Describe the bug

PublishedElection has a maxCensusSize getter that should return the information received via census.maxCensusSize field in the API, but it's always undefined.

To Reproduce

Grab any election information, and try to access the value via election.maxCensusSize

Current behavior

Returns undefined

Expected behavior

Should return the expected maxCensusSize value the API is properly returning.

Additional context

API response:
imatge

Stored published election data in memory:
imatge

@elboletaire elboletaire added the bug Something isn't working label Aug 4, 2023
@elboletaire
Copy link
Member Author

elboletaire commented Aug 4, 2023

Looks like the issue is that it is being expected via params.maxCensusSize, but when building it in the client we're not passing the expected maxCensusSize param. Trace:

  • Election's maxCensusSize definition:
    this._maxCensusSize = params.maxCensusSize;
  • PublishedElection passing to super:
    maxCensusSize: params.maxCensusSize,
  • Client creating PublishedElection (here's where's missing):

    vocdoni-sdk/src/client.ts

    Lines 513 to 562 in 6b8347e

    PublishedElection.build({
    id: electionInfo.electionId,
    organizationId: electionInfo.organizationId,
    title: electionInfo.metadata?.title,
    description: electionInfo.metadata?.description,
    header: electionInfo.metadata?.media.header,
    streamUri: electionInfo.metadata?.media.streamUri,
    meta: electionInfo.metadata?.meta,
    startDate: electionInfo.startDate,
    endDate: electionInfo.endDate,
    census: new PublishedCensus(
    electionInfo.census.censusRoot,
    electionInfo.census.censusURL,
    Census.censusTypeFromCensusOrigin(electionInfo.census.censusOrigin),
    censusInfo.size,
    censusInfo.weight
    ),
    status: electionInfo.status,
    voteCount: electionInfo.voteCount,
    finalResults: electionInfo.finalResults,
    results: electionInfo.result,
    metadataURL: electionInfo.metadataURL,
    creationTime: electionInfo.creationTime,
    electionType: {
    autoStart: electionInfo.electionMode.autoStart,
    interruptible: electionInfo.electionMode.interruptible,
    dynamicCensus: electionInfo.electionMode.dynamicCensus,
    secretUntilTheEnd: electionInfo.voteMode.encryptedVotes,
    anonymous: electionInfo.voteMode.anonymous,
    },
    voteType: {
    uniqueChoices: electionInfo.voteMode.uniqueValues,
    maxVoteOverwrites: electionInfo.tallyMode.maxVoteOverwrites,
    costFromWeight: electionInfo.voteMode.costFromWeight,
    costExponent: electionInfo.tallyMode.costExponent,
    maxCount: electionInfo.tallyMode.maxCount,
    maxValue: electionInfo.tallyMode.maxValue,
    maxTotalCost: electionInfo.tallyMode.maxTotalCost,
    },
    questions: electionInfo.metadata?.questions.map((question, qIndex) => ({
    title: question.title,
    description: question.description,
    choices: question.choices.map((choice, cIndex) => ({
    title: choice.title,
    value: choice.value,
    results: electionInfo.result ? electionInfo.result[qIndex][cIndex] : null,
    })),
    })),
    raw: electionInfo,
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant