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

indexer: static vote_count plus fixes #1173

Merged
merged 3 commits into from
Oct 31, 2023
Merged

indexer: static vote_count plus fixes #1173

merged 3 commits into from
Oct 31, 2023

Conversation

mvdan
Copy link
Contributor

@mvdan mvdan commented Oct 30, 2023

(see commit messages - please do not squash)

Updates #1170.

mvdan added 2 commits October 30, 2023 21:38
While reading the code, I remembered that we store big integers
in sqlite in quoted strings, for the sake of consistent JSON encoding.
We weren't quoting in the fallback case if vote.Weight is nil,
which could lead to decoding errors if we use that value.
Otherwise the map just keeps increasing in size forever,
meaning that we do more and more busy work over time.
It's surprising that we hadn't caught this bug for a long time.

While here, initialize and clear both "by process ID" maps consistently.
@mvdan mvdan requested a review from p4u October 30, 2023 22:23
We used to do this a while back, and replaced it with a COUNT plus JOIN
with sqlite since the data was all in sqlite.

However, we're now adding processes where the votes are not indexed,
and we want to specify what the vote count is as a static integer.

Make indexertypes.Process.VoteCount visible in JSON as well now,
since it's a proper column and no longer derived data via COUNT.

Updates vocdoni#1170.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 6699456848

  • 37 of 47 (78.72%) changed or added relevant lines in 6 files are covered.
  • 7 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.02%) to 61.845%

Changes Missing Coverage Covered Lines Changed/Added Lines %
vochain/indexer/indexer.go 25 29 86.21%
vochain/indexer/db/db.go 2 8 25.0%
Files with Coverage Reduction New Missed Lines %
api/accounts.go 2 47.39%
apiclient/account.go 2 40.92%
cmd/end2endtest/account.go 3 68.72%
Totals Coverage Status
Change from base Build 6692851655: 0.02%
Covered Lines: 14228
Relevant Lines: 23006

💛 - Coveralls

@p4u p4u merged commit 20bbe9c into vocdoni:main Oct 31, 2023
7 checks passed
@mvdan mvdan deleted the vote-count branch November 2, 2023 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants