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

api: endpoint /elections now filters by title and description (WIP) #1373

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

altergui
Copy link
Contributor

No description provided.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 10596993179

Details

  • 12 of 13 (92.31%) changed or added relevant lines in 3 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 62.26%

Changes Missing Coverage Covered Lines Changed/Added Lines %
vochain/indexer/process.go 2 3 66.67%
Files with Coverage Reduction New Missed Lines %
vochain/transaction/admin_tx.go 2 48.81%
vochain/transaction/transaction.go 2 59.23%
Totals Coverage Status
Change from base Build 10522335386: 0.02%
Covered Lines: 16532
Relevant Lines: 26553

💛 - Coveralls

@altergui altergui force-pushed the feat/api-elections-title-description branch from 05713be to f72f3d4 Compare August 28, 2024 13:36
Comment on lines +330 to +342
// TODO: abstract all of this somewhere else and just call from here
metadataBytes, err := d.Retrieve(stgCtx, uri, MaxOffchainFileSize)
if err != nil {
log.Warnf("cannot get metadata from %s: %v", election.MetadataURL, err)
} else {
// if metadata exists and is not encrypted, add it to the indexed election
// if the metadata is not encrypted, unmarshal it, otherwise store it as bytes
if !election.ElectionMode.EncryptedMetaData {
electionMetadata := api.ElectionMetadata{}
if err := json.Unmarshal(metadataBytes, &electionMetadata); err != nil {
log.Warnf("cannot unmarshal metadata from %s: %v", election.MetadataURL, err)
}
election.Metadata = &electionMetadata
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't work at all, doesn't even compile, it's just a copypaste from api/elections.go

@@ -26,6 +28,7 @@ type importItem struct {
itemType int
uri string
censusRoot string
pid types.HexBytes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added this so offchaindatahandler can keep track of which process metadata it is, and tell indexer to update that process

@@ -87,7 +92,7 @@ func (d *OffChainDataHandler) Commit(_ uint32) error {
go d.enqueueOffchainCensus(item.censusRoot, item.uri)
case itemTypeElectionMetadata, itemTypeAccountMetadata:
log.Infow("importing data", "type", itemTypesToString[item.itemType], "uri", item.uri)
go d.enqueueMetadata(item.uri)
go d.enqueueMetadata(item)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, i pass the whole item so i can have access to all the info about the item queued

@@ -42,6 +45,7 @@ var itemTypesToString = map[int]string{
// offchain data (usually on IPFS).
type OffChainDataHandler struct {
vochain *vochain.BaseApplication
indexer *indexer.Indexer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't like this, but i can't think of a better option right now to communicate offchaindatahandler and indexer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a (cleaner?) alternative would be to add a new Event in EventListeners that is "MetadataReady" or something like this, that indexer can subscribe (and trigger the update in the db) and offchaindatahandler can trigger the event when the metadata is downloaded

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.

2 participants