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

Don't rerun dashcard queries when switching tabs without parameter changes #40783

Merged
merged 4 commits into from
Mar 29, 2024

Conversation

kulyk
Copy link
Member

@kulyk kulyk commented Mar 29, 2024

Addresses #39863

There are a few places in the fetchCardData dashboard action where we're checking if queries or parameters have changed since the last run (here is an example) to decide if we need to refresh data. For versions 49 and lower, there's an unhandled case with parameters without a value. They don't have a value property in the last run object, but they have value: null in the other object we're using for comparison. We trigger fetchCardData when switching the dashboard tab, and this comparison logic should prevent us from redundant reruns when neither queries or parameters change, but this wasn't working as expected.

On master this was fixed by #35465, the BE started to return value: null in query responses. This PR adds an E2E test to ensure the problem won't come back and adds a FE safety net (to be backported to 48 and 49)

To reproduce

  1. Create a dashboard with two tabs, one question per tab, and one filter linked to both questions
  2. Open Tab 1, wait for query to finish
  3. Open Tab 2, wait for query to finish
  4. Return to Tab 1, ensure we're not rerunning the query
  5. Return to Tab 2, ensure we're not rerunning the query

@kulyk kulyk added support/Repro backport Automatically create PR on current release branch on merge .Team/DashViz Dashboard and Viz team labels Mar 29, 2024
@kulyk kulyk requested review from a team March 29, 2024 14:23
@kulyk kulyk self-assigned this Mar 29, 2024
Copy link
Contributor

@uladzimirdev uladzimirdev left a comment

Choose a reason for hiding this comment

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

There was another flaky test, which was checking exactly if the request is fired or not on tab change, but I can't find it. maybe it needs to be removed/adjusted after this one

cy.wait("@dashcardQuery");
cy.get("@dashcardQuery.all").should("have.length", 3);

// Rerun 2nd tab query with new parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: instead of comments, use cy.log

// Rerun 1st tab query with new parameters
setDateFilter();
cy.wait("@dashcardQuery");
cy.get("@dashcardQuery.all").should("have.length", 3);
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 found that way of testing number of requests as very unreliable (number can vary from run to run), but I hope it works in your case

Copy link

replay-io bot commented Mar 29, 2024

Status Complete ↗︎
Commit ee9decb
Results
⚠️ 5 Flaky
2386 Passed

@kulyk kulyk force-pushed the 39863-fix-redundant-query-reruns branch from 1f1bb41 to ee9decb Compare March 29, 2024 16:33
@kulyk kulyk merged commit bd33c86 into master Mar 29, 2024
107 checks passed
@kulyk kulyk deleted the 39863-fix-redundant-query-reruns branch March 29, 2024 17:19
@kulyk
Copy link
Member Author

kulyk commented Mar 29, 2024

@metabase-bot backport release-x.48.x

Copy link

@kulyk Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

github-actions bot pushed a commit that referenced this pull request Mar 29, 2024
…anges (#40783)

* Add E2E test

* Move `getDatasetQueryParams` to `data-fetching.js`

* Use `null` as a parameter value when missing

* Fix missing default `datasetQuery`
github-actions bot pushed a commit that referenced this pull request Mar 29, 2024
…anges (#40783)

* Add E2E test

* Move `getDatasetQueryParams` to `data-fetching.js`

* Use `null` as a parameter value when missing

* Fix missing default `datasetQuery`
metabase-bot bot added a commit that referenced this pull request Mar 29, 2024
…anges (#40783) (#40823)

* Add E2E test

* Move `getDatasetQueryParams` to `data-fetching.js`

* Use `null` as a parameter value when missing

* Fix missing default `datasetQuery`

Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>
metabase-bot bot added a commit that referenced this pull request Mar 30, 2024
…t parameter changes" (#40824)

* Don't rerun dashcard queries when switching tabs without parameter changes (#40783)

* Add E2E test

* Move `getDatasetQueryParams` to `data-fetching.js`

* Use `null` as a parameter value when missing

* Fix missing default `datasetQuery`

* Fix E2E test

---------

Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>
@crisptrutski crisptrutski added this to the 0.48.10 milestone Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Automatically create PR on current release branch on merge support/Repro .Team/DashViz Dashboard and Viz team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants