api: endpoint /elections now filters by title and description (WIP)#1373
api: endpoint /elections now filters by title and description (WIP)#1373
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.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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.