镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[Refactor][Framework] Refactor Extractors and Converters to use Generics #3616

Closed

Description

@keon94

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

Activity

  1. github-actions commented on Nov 29, 2022

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.

  2. added this to the v0.16.0 milestone on Jan 3, 2023
  3. github-actions commented on Feb 20, 2023

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.

  4. Startrekzky commented on Feb 20, 2023

    @Startrekzky
    Contributor

    Bump

  5. deleted a comment from github-actions on Feb 20, 2023
  6. coldgust commented on Mar 6, 2023

    @coldgust
    Member

    Hello, I would like to finish this task,could you assign this to me?

  7. 7 remaining items

  8. Dev79844 commented on Jun 20, 2023

    @Dev79844

    Hey @keon94 ! Is anyone working on this issue? If not can you assign it to me

  9. keon94 commented on Jun 20, 2023

    @keon94
    ContributorAuthor

    @Dev79844 I don't believe so. Sure, you can have it. Thanks for taking it on.

  10. assigned and unassigned on Jun 20, 2023
  11. github-actions commented on Jul 26, 2023

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.

  12. github-actions commented on Sep 25, 2023

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

  13. added this to the v0.21 milestone on Sep 25, 2023
  14. github-actions commented on Nov 25, 2023

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

  15. github-actions commented on Dec 2, 2023

    @github-actions
    Contributor

    This issue has been closed because it has been inactive for a long time. You can reopen it if you encounter the similar problem in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions