Skip to content
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

refactor: Hubspot getMarshalledData -> getDataMarshaller #1360

Merged
merged 2 commits into from
Feb 14, 2025

Conversation

laurenzlong
Copy link
Contributor

@laurenzlong laurenzlong commented Feb 13, 2025

No functional change, some refactors to make code easier to understand & reduce repetitive code:

  • renamed getMarshalledData to getDataMarshaller to make it more obvious it's a higher order function
  • revised getDataMarshaller to handle case when len(fields) is 0, so that GetRecordsFromIds doesn't need to implement it that logic
  • also modified the test the check that full raw record is returned, I'm surprised it wasn't failing before

@laurenzlong laurenzlong requested review from a team, jlimatampersand and Cobalt0s and removed request for a team February 13, 2025 20:13
Copy link
Collaborator

@Cobalt0s Cobalt0s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

func (c *Connector) getMarshalledData(
// getDataMarshaller returns a function that accepts a list of records and fields
// and returns a list of structured data ([]ReadResultRow).
func (c *Connector) getDataMarshaller(
Copy link
Collaborator

@Cobalt0s Cobalt0s Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RajatPawar this PR is related to this function.

Hubspot is on the same list as Klaviyo/Atlassian/Keap, etc. The implementation would become more consize if this function would work with *ajson.Node which is easier for parsing into the struct or queried using custom jsonquery package.

Currently, common.ParseResult enforces the use of map[string]any, adding unnecessary complexity to the code for some connectors. Adding flexibility to either or would resolve this.

Once the decision is made regarding common.ParseResult, I will revisit Hubspot implementation to simplify it even further. Essentially we need to convert ajson.Node into struct {"id":"", "properties": {}}.

@laurenzlong laurenzlong merged commit 26947c4 into main Feb 14, 2025
5 checks passed
@laurenzlong laurenzlong deleted the ll-refactorgetdatamarshaller branch February 14, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants