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

fix(ui): properly map over queryBuilder tags and set default values #16105

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

hoorayimhelping
Copy link
Contributor

@hoorayimhelping hoorayimhelping commented Dec 4, 2019

Closes HoneyBadger #12

For the purposes of expediency and fixing a terrible prod bug, this bypasses good hygiene like tests. I added an issue to follow up on that.

Error was introduced here.

I initially noticed a lot of duplication of the initial state of tags, so I added the notion of an initial tag. Tags in query builder parlance map to the boxes at the bottom of the query builder. So each query that was built with the builder has an array of tags associated with it. On load, these tags are nulled out to an initial state. Here is a kinda psuedocode explanation of what that looks like:

const initialStateHelperTags = [{
  aggregateFunctionType: 'filter',
  keys: [],
  keysSearchTerm: '',
  keysStatus: RemoteDataState.NotStarted,
  values: [],
  valuesSearchTerm: '',
  valuesStatus: RemoteDataState.NotStarted,
}]

queryBuilder: {
  tags: [
    initialStateHelperTags[0],
    initialStateHelperTags[0],
    initialStateHelperTags[0]
  ]
}

When the query builder loads, it should loop over all the tag groups in the query builder and set them to default values.

What my buggy code did was this:

queryBuilder.tags = initialStateHelperTags

See the differences? It set the array of tags, which maps to each filtered section of a query, to an array with with a single item, the default tag.

big oof.

Testing Instructions:

On master:

  1. Create a query with the query builder.
  2. Load that query
  3. 💥

Checkout this branch:

  1. git checkout bs_fix_undefined_tags
  2. Load the query you saved before
  3. 🎉

@hoorayimhelping hoorayimhelping requested a review from a team December 4, 2019 00:42
@hoorayimhelping hoorayimhelping changed the title fix(ui): properly map over queryBuilder tags and set default values, rather than setting all tags to default values fix(ui): properly map over queryBuilder tags and set default values Dec 4, 2019
@hoorayimhelping hoorayimhelping requested review from a team December 4, 2019 01:07
@ghost ghost requested review from 121watts and drdelambre and removed request for a team December 4, 2019 01:07
@hoorayimhelping hoorayimhelping merged commit e52705d into master Dec 4, 2019
@hoorayimhelping hoorayimhelping deleted the bs_fix_undefined_tags branch December 4, 2019 01:41
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