keon94 opened a new issue, #3616:
URL: https://github.com/apache/incubator-devlake/issues/3616
## 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:
```go
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:
```go
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)
## Related issues
n/a
## Additional context
n/a
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]