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

chore: Unwrap JSONB columns in analytics_summary view #2798

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Feb 15, 2024

image

What does this PR do?

  • Unwraps user_agent column into platform, os, and browser
  • Unwraps metadata column into change_metadata, back_metadata, help_metadata and selected_urls

I'll cross check with @zz-hh-aa before we move this to production that this won't be a breaking change

/**
* Describes the value held in analytics_logs.metadata
*/
type Metadata =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might be a little redundant but it does mean we now have a documented type of the data held in this column.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit

I think this is worth adding and I think it better expresses what's going on I'm not sure it's 100% of the way there.

If I understand the intention of this correctly then there'd be a type called Metadata which would capture the structure of data that could be stored on the metadata column. The suggested union types shows that the full Metadata is never actually written in one mutation and is instead only even one of the nested types i.e. it might be HelpClickMetata or SelectedUrlsMetadata but these are done on different mutations.

To take the suggested change a bit further I'd add types for all of the discreet metadata and update so that whenever the metadata column is written to it is of type Metadata.

I've added a PR fro this here: #2805

@DafyddLlyr
Copy link
Contributor Author

@zz-hh-aa
Copy link
Collaborator

Had a quick look and don't think it'll break anything (but it will help with some yet-unanswered questions!).

Copy link

github-actions bot commented Feb 15, 2024

Removed vultr server and associated DNS entries

@DafyddLlyr
Copy link
Contributor Author

@Mike-Heneghan Please feel free to take over / amend / fix / merge this branch next week so that this can progress 👍

Copy link
Contributor

@Mike-Heneghan Mike-Heneghan left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up @DafyddLlyr it's an awesome change!

I had one comment on the change to types which is non-blocking but I have a PR to extend it a little which I'd be keen to get your perspective on but there's no rush to add.


await publicClient.mutate({
mutation: gql`
mutation UpdateHaInitiatedBackwardsNavigation(
mutation UpdateHasInitiatedBackwardsNavigation(
Copy link
Contributor

Choose a reason for hiding this comment

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

Great spot!

/**
* Describes the value held in analytics_logs.metadata
*/
type Metadata =
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

I think this is worth adding and I think it better expresses what's going on I'm not sure it's 100% of the way there.

If I understand the intention of this correctly then there'd be a type called Metadata which would capture the structure of data that could be stored on the metadata column. The suggested union types shows that the full Metadata is never actually written in one mutation and is instead only even one of the nested types i.e. it might be HelpClickMetata or SelectedUrlsMetadata but these are done on different mutations.

To take the suggested change a bit further I'd add types for all of the discreet metadata and update so that whenever the metadata column is written to it is of type Metadata.

I've added a PR fro this here: #2805

Copy link
Contributor

Choose a reason for hiding this comment

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

This is such a useful change 🥳

Copy link
Contributor

Choose a reason for hiding this comment

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

nit

run_sql_migrations isn't a super meaningful name so it might be nice to call it something along the lines of alter_view_analytics_summary_unfold_metadata

@Mike-Heneghan Mike-Heneghan force-pushed the dp/unfold-metadata-columns branch from 177eadc to 18b8332 Compare February 21, 2024 11:01
@Mike-Heneghan Mike-Heneghan merged commit e0f5114 into main Feb 21, 2024
12 checks passed
@Mike-Heneghan Mike-Heneghan deleted the dp/unfold-metadata-columns branch February 21, 2024 12:20
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.

3 participants