-
Notifications
You must be signed in to change notification settings - Fork 670
Closed
Labels
Stalegood first issueGood for newcomersGood for newcomerstype/refactorThis issue is to refactor existing codeThis issue is to refactor existing code
Milestone
Description
What and why to refactor
Extract functions use raw objects which they manually have to json-deserialize into predefined structs. This is needless boilerplate now that Go supports generics. Refactor the api_extractor.go (and other relevant framework files) to performs these deserializations under the hood and send the resulting Go structs to the user (Extract) functions.
The Converters suffer from this as well, although there's less boilerplate there. Refactor accordingly.
Describe the solution you'd like
Example:
currently we have:
Extract: func(row *helper.RawData) ([]interface{}, errors.Error) {
apiAccountOrgs := &[]GithubAccountOrgsResponse{}
err := json.Unmarshal(row.Data, apiAccountOrgs)
if err != nil {
return nil, errors.Convert(err)
}
simpleAccount := &SimpleAccountWithId{}
err = json.Unmarshal(row.Input, simpleAccount)
if err != nil {
return nil, errors.Convert(err)
}
// more logic...
}it should become like:
Extract: func(orgs []GithubAccountOrgsResponse, input *SimpleAccountWithId) ([]interface{}, errors.Error) {
// more logic...
}The API extractor will need to take two generic parameters: for the row data and the row input - initialization will look like this:
helper.NewApiExtractor[[]GithubAccountOrgsResponse, SimpleAccountWithId](...)Related issues
n/a
Additional context
n/a
likyh
Metadata
Metadata
Assignees
Labels
Stalegood first issueGood for newcomersGood for newcomerstype/refactorThis issue is to refactor existing codeThis issue is to refactor existing code