-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 10596993179Details
💛 - Coveralls |
05713be
to
f72f3d4
Compare
// 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
No description provided.