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

QueryHistory: Improve handling of mixed datasource entries #62214

Merged
merged 9 commits into from
Feb 1, 2023

Conversation

Elfo404
Copy link
Member

@Elfo404 Elfo404 commented Jan 26, 2023

What is this feature?

Improves QueryHistory display and handling of mixed datasource queries in Explore.

A mixed entry where all datasources implement getQueryDisplayText:
Screenshot 2023-01-26 at 13 48 42
note that explore's root datasource was set to Mixed. when an entry datasource does not match explore's root datasource, this would be shown instead:
Screenshot 2023-01-26 at 13 54 10

A regular entry wit no mixed queries:
Screenshot 2023-01-26 at 13 52 55

A mixed entry with one of the datasources that does not implement getQueryDisplayText:
Screenshot 2023-01-26 at 13 48 16

open points:

A mixed entry that has queries from an unavailable datasources still shows an active run queries button. upon clicking it Explore will show an error i the query row stating that the datasource was not found (for each query that has a missing datasource).

Screenshot 2023-01-26 at 13 59 00

Screenshot 2023-01-26 at 13 48 33

Not sure what the best approach is here: removing the queries without a datasource seem sensible when a mixed entry also contains queries for which the datasource is still available. and in case no query has a datasource available maybe the card should behave like a regular entry; disabling the run query button (or probably removing it in the first place)

Screenshot 2023-01-26 at 14 04 58

opinions?

Why do we need this feature?

We are gradually introducing support for Mixed datasource queries in Explore. Query History was not initially meant to handle Mixed datasource entries.

Which issue(s) does this PR fix?:

Fixes #61089

Special notes for your reviewer:

@Elfo404 Elfo404 added pr/early-feedback WIP state but looking for early feedback area/explore area/frontend add to changelog no-backport Skip backport of PR labels Jan 26, 2023
@Elfo404 Elfo404 added this to the 9.4.0 milestone Jan 26, 2023
@Elfo404 Elfo404 requested review from a team as code owners January 26, 2023 14:06
@Elfo404 Elfo404 requested review from axelavargas, ivanortegaalba, joshhunt and ashharrison90 and removed request for a team January 26, 2023 14:06
@gelicia
Copy link
Contributor

gelicia commented Jan 26, 2023

For the cases where a datasource was removed, I would recommend graying out the query in the UI, and greying out the button if all queries in the history are greyed out. I think we should still keep the text in the db as usual and display it in case the user has a query or something they want to copy/paste out of there.

@github-actions
Copy link
Contributor

Backend code coverage report for PR #62214
No changes

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2023

Frontend code coverage report for PR #62214

Plugin Main PR Difference
explore 85.82% 86.05% .23%

@Elfo404
Copy link
Member Author

Elfo404 commented Jan 30, 2023

after discussing briefly this last week we decided to disable running queries if at least one of the queries in an entry has a missing datasource.
Screenshot 2023-01-30 at 12 18 07

{ query: 'query3', refId: 'C' },
],
},
});
const datasourceName = await screen.findByLabelText('Data source name');
expect(datasourceName).toHaveTextContent('Data source does not exist anymore');
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we want to test the button is disabled here too?

setQueries(exploreId, queriesToRun);
} else {
setQueries(exploreId, queriesToRun);
await changeDatasource(exploreId, query.datasourceUid);
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 importing queries doesn't make any sense here - thank you!

@@ -161,42 +152,68 @@ export function RichHistoryCard(props: Props) {
} = props;
const [activeUpdateComment, setActiveUpdateComment] = useState(false);
const [comment, setComment] = useState<string | undefined>(query.comment);
const [queryDsInstance, setQueryDsInstance] = useState<DataSourceApi | undefined>(undefined);
const { value, loading } = useAsync(async () => {
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 the nittyest of nits, but what do you think about something besides value for this variable name? I know it's literally the value of the rich history card so your variable name makes sense, but we have areas reading queries values from props and some from this, it might be helpful to either define this variable name or leave a comment. Maybe like dsPopulatedData dsEnhancedRecord for possible variable names?

Copy link
Member Author

@Elfo404 Elfo404 Jan 30, 2023

Choose a reason for hiding this comment

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

tbh i think with a few rafactorings that happened variable names in this component went all bonkers (like queryDsInstance, dsInstance, query (which is instead historyEntry) ), i actually settled for value because it felt the lcearer to me :D

i wanted to rename ~all the things but didn't want to pollute the PR with a bunch of renaming that would have made reviewing harder. if it's ok tho i'll just push an extra commit to do all the renaming. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah, I understand where you're coming from. Feel free to leave it, it's easy enough to understand what's going on

Copy link
Member Author

Choose a reason for hiding this comment

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

i'll create another issue when merging this and a follow up pr to address all the ambiguous names in this file

Copy link
Contributor

@gelicia gelicia left a comment

Choose a reason for hiding this comment

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

Just a couple small nits but overall this looks great! Glad to see this problem solved :D

@Elfo404 Elfo404 modified the milestones: 9.4.0, 9.5.0 Jan 31, 2023
Copy link
Contributor

@ifrost ifrost left a comment

Choose a reason for hiding this comment

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

@Elfo404 Elfo404 merged commit c66ab3a into main Feb 1, 2023
@Elfo404 Elfo404 deleted the gio/feat/query-history-mixed-ds branch February 1, 2023 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QueryHistory: Improve History Card display of queries when using mixed datasource
4 participants