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

Poll for results in parameterized embeds #3752

Merged
merged 23 commits into from
May 6, 2019
Merged

Conversation

rauchy
Copy link
Contributor

@rauchy rauchy commented May 1, 2019

What type of PR is this? (check all applicable)

  • Bug Fix

Description

Turns out that parameters in parameterized embeds did not poll for query results. This PR fixes this by allowing polling of job status by api_key, followed by fetching of the latest cached query result.

Related Tickets & Documents

Fixes the second part of #3719

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

poll-in-embeds

Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

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

See comment & the UI need to show load status (similar to what we do with dashboard widgets).

@@ -9,5 +9,8 @@
<i class="zmdi zmdi-settings"></i>
</button>
<parameter-value-input param="param"></parameter-value-input>
<button class="m-l-5 btn btn-primary" ng-if="onRefresh" ng-click="onRefresh()" title="Refresh Dataset">
<span class="zmdi zmdi-play"></span>
</button>
Copy link
Member

Choose a reason for hiding this comment

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

Considering this just executes query refresh, why not put it outside the parameters component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parameter directive's containing div is a block, so putting it outside would cause the button to drop below.

Copy link
Member

Choose a reason for hiding this comment

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

🤔 not ideal, but it's temporary, so YOLO... maybe add a comment for @gabrieldutra to remove this once he's done with #3737 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙄
hey, @gabrieldutra! remove this once you're done with #3737!

Copy link
Member

Choose a reason for hiding this comment

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

@rauchy
Copy link
Contributor Author

rauchy commented May 2, 2019

@arikfr following 5653bd4:

timer

* Redirect to default parameter values when parameters are missing in
embedded visualizations

* Revert "Redirect to default parameter values when parameters are missing in"

This reverts commit 43c6550.

* load all data after page is loaded

* return no data only when parameters are missing

* data binding no longer required

* show an error on embeds that fail to load

* data binding no longer required

* present full-page error when dealing with unsafe queries
@rauchy
Copy link
Contributor Author

rauchy commented May 2, 2019

@arikfr #3741 has been merged into this, and now this fixes both sections of #3719.

@rauchy rauchy requested a review from arikfr May 2, 2019 10:32
@arikfr
Copy link
Member

arikfr commented May 2, 2019

Three things that immediately stood out:

  1. There should be a message saying a parameter is missing value. Example
  2. There needs to be only one "Refresh" button.
  3. When you change a value in the parameters input boxes, the whole UI flashes but nothing happens (until you click on the refresh button).

@rauchy
Copy link
Contributor Author

rauchy commented May 2, 2019

  1. 740472b
  2. 7389725
  3. Not sure about this one - when you change values, it fetches cached results for that values, so assuming there are cached results - you'll see them. When you hit "refresh", it will poll for changes. Which behavior would you expect here? Would you like to see a message prompting you to hit "Refresh" to bring back values?


document.querySelector('body').classList.add('headless');

this.refreshQueryResults();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

if (this.query.is_safe) {
this.refreshQueryResults();
} else {
this.error = "Can't embed queries with text parameters.";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd avoid being too specific on what are unsafe queries here, as the definition is subject to change soon and this message will likely be left unattended.

Copy link
Member

Choose a reason for hiding this comment

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

I doubt it will change so soon... and until we have documentation about what are safe parameters, it's better to have a meaningful message.

@arikfr arikfr merged commit 9fec3ca into master May 6, 2019
@arikfr arikfr deleted the poll-for-results-in-embeds branch May 6, 2019 06:15
@arikfr
Copy link
Member

arikfr commented May 6, 2019

YOLO 😎

harveyrendell pushed a commit to pushpay/redash that referenced this pull request Nov 14, 2019
* add an endpoint for fetching job using a query's api_key

* when unauthenticated, use api_key to get job, and fetch the latest query
result (as opposed to fetching the query result by ID)

* add 'refresh dataset' button to parameters directive

* fix scope error introduced by earlier commit

* show timer when refreshing results

* Show input for missing parameters in embedded visualizations (getredash#3741)

* Redirect to default parameter values when parameters are missing in
embedded visualizations

* Revert "Redirect to default parameter values when parameters are missing in"

This reverts commit 43c6550.

* load all data after page is loaded

* return no data only when parameters are missing

* data binding no longer required

* show an error on embeds that fail to load

* data binding no longer required

* present full-page error when dealing with unsafe queries

* don't render the execute button for each parameter

* show 'missing parameter value' error

* Don't reload the whole page when parameter value changes.

* Set API key and load config before rendering.

* Add Query#hasParameters method.

* Don't show download controls for parameterized queries (they won't work).

* Use getUrl to construct a correct query link.

* WIP: have a single way to load results

1. This preloads the query before rendering the page, so we can benefit from using default parameters & make the logic in component simpler.
2. Use a single way to load results, to make sure we do polling when try to load the query results for the first time.

* Show persistent errors and finish loading logic.

* Check if query is safe and show message otherwise.

* Fix test for unsafe parameters embed.

* wait for query results to return before taking snapshot
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