Skip to content

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

Draft
altergui wants to merge 2 commits intomainfrom
feat/api-elections-title-description
Draft

api: endpoint /elections now filters by title and description (WIP)#1373
altergui wants to merge 2 commits intomainfrom
feat/api-elections-title-description

Conversation

@altergui
Copy link
Copy Markdown
Contributor

No description provided.

@coveralls
Copy link
Copy Markdown

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
Copy Markdown
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

itemType int
uri string
censusRoot string
pid types.HexBytes
Copy link
Copy Markdown
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

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
Copy Markdown
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

// offchain data (usually on IPFS).
type OffChainDataHandler struct {
vochain *vochain.BaseApplication
indexer *indexer.Indexer
Copy link
Copy Markdown
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
Copy Markdown
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