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

feat: Improve sorting for new chart dataset select #16414

Closed
wants to merge 1 commit into from

Conversation

etr2460
Copy link
Member

@etr2460 etr2460 commented Aug 24, 2021

SUMMARY

#16200 updated the add chart page and as a side effect started showing virtual datasets in the dropdown. This was probably a good thing all told, but at Airbnb we had a bunch of virtual datasets with similar names to physical datasets that then made it difficult/impossible to find the original physical dataset in the selector.

This change will elevate an exact match dataset name to the top of the selector if one exists.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2021-08-23 at 5 27 33 PM
Screen Shot 2021-08-23 at 5 27 44 PM

TESTING INSTRUCTIONS

created datasets with very similar names, ensured that the one with an exact matching name appears first

ADDITIONAL INFORMATION

  • Has associated issue: [Gallery] Less-blocking creating new chart flow #16173
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

to: @michael-s-molina @ktmud @suddjian

label: this.newLabel(item),
labelText: item.table_name,
}))
.sort((a: { labelText: string }, b: { labelText: string }) =>
Copy link
Member Author

Choose a reason for hiding this comment

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

fun fact, this didn't do anything since the selector re-sorts the options again :P Adding a filterSort prop to the selector is how you actually sort the items in the dropdown

Copy link
Member

Choose a reason for hiding this comment

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

@etr2460 filterSort only sorts when searching. If the user just opens the select the values will be unsorted if we remove these lines. We'll probably need to apply your sort function here as well 😉

Screen.Recording.2021-08-24.at.7.29.40.AM.mov

Copy link
Member

@michael-s-molina michael-s-molina Aug 24, 2021

Choose a reason for hiding this comment

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

@etr2460 The ideal solution would be to disable the filterSort when the Select is in async mode and sort the values on the server-side to correctly handle the pagination. This endpoint is not respecting the order_column and order_direction props, so we would need to fix it.

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, interesting, i didn't even see results rendering when clicking into the modal without typing anything. although maybe that's because in our env we have too many datasets so it didn't render fast enough. i'll see what i can do to fix the sorting for all use cases here

Copy link
Member

@michael-s-molina michael-s-molina Aug 24, 2021

Choose a reason for hiding this comment

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

@etr2460 for the scenario where the paginated query with no search (100 results by default) is heavy, we created a prop called fetchOnlyOnSearch. What we need to do is make it configurable by organizations.

@codecov
Copy link

codecov bot commented Aug 24, 2021

Codecov Report

Merging #16414 (7ea08cb) into master (c768941) will decrease coverage by 0.01%.
The diff coverage is 14.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16414      +/-   ##
==========================================
- Coverage   76.55%   76.54%   -0.02%     
==========================================
  Files        1000     1000              
  Lines       53483    53495      +12     
  Branches     6818     6820       +2     
==========================================
+ Hits        40945    40947       +2     
- Misses      12300    12310      +10     
  Partials      238      238              
Flag Coverage Δ
javascript 70.67% <14.28%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/components/Select/Select.tsx 76.57% <ø> (ø)
...perset-frontend/src/addSlice/AddSliceContainer.tsx 51.31% <14.28%> (-5.61%) ⬇️
...c/views/CRUD/data/database/DatabaseModal/index.tsx 44.24% <0.00%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c768941...7ea08cb. Read the comment docs.

@@ -194,6 +196,8 @@ export default class AddSliceContainer extends React.PureComponent<
this.newLabel = this.newLabel.bind(this);
this.loadDatasources = this.loadDatasources.bind(this);
this.handleFilterOption = this.handleFilterOption.bind(this);
Copy link
Member

@ktmud ktmud Aug 24, 2021

Choose a reason for hiding this comment

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

I think we should just replace both filterOption and filterSort with match-sorter. It has worked well for the Explore page Dataset side panel.

This basically means controlling the filtering outside of AntD Select---which should give more consistent filtering behavior across the board.

Copy link
Member Author

Choose a reason for hiding this comment

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

woah, i haven't seen match-sorter yet. i think that'll work? although antd select has made it tricky to take control over filtering and sorting. i'll play with it

Copy link
Member Author

Choose a reason for hiding this comment

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

@ktmud Do you think we should try and add this to the default Select component in superset? just apply it across the board?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that'd be ideal. The Select component can provide a matchSorterKey prop to override the default match-sorting keys.

Copy link
Member

@michael-s-molina michael-s-molina Aug 24, 2021

Choose a reason for hiding this comment

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

@ktmud @etr2460 filterSort is useful when all the values are present in the select. It's less useful when we are using the async version of our select, which is the majority of the cases. In the async version, the sorting should be done on the server-side before the pagination to ensure the correct results are returned. Client-side sorting on paginated requests can produce wrong results. We can use match-sorter for the static version but so far we haven't found any case where the default sorting wasn't sufficient. I think the best way to fix this is to make the endpoint respect the sorting parameters and implement the exact match behavior on the server-side.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, bumping exact matches is probably good enough for now.

It'd definitely be nice to have paginated backend searches. Hopefully we'll come up with a solution that's generalized enough even for omni-searches in the future.

Copy link
Member

Choose a reason for hiding this comment

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

If we're going down this path, then maybe we need elasticsearch on the backend :P mysql isn't great for search

I'd love to make this an optional search backend! 🍻

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 think we all agree here. Thanks @villebro ! do you think i should close this pr then?

Copy link
Member

Choose a reason for hiding this comment

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

@etr2460 I have a POC in mind but it would introduce a fairly significant change on FAB, so I want to discuss it first with Daniel before starting the work, and he's currently on PTO. I don't expect my POC to be ready for another few weeks (will require review and a new release), so if this is needed in the interim then we can merge this IMO unless @michael-s-molina has some objections.

Copy link
Member

Choose a reason for hiding this comment

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

@villebro I don't have any objections as a temporary solution. We can come back later and remove the client-side sorting. We'll probably need to do that anyway with other selects.

Before merging, we need to also sort the values when the user opens the select as stated here #16414 (comment)

@john-bodley
Copy link
Member

@villebro based on @michael-s-molina's comment are you ok moving forward with said change, especially given—per @etr2460's PR description—the UX is severely impacted at Airbnb or likely any other installation which contains a large number of datasets etc.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 16, 2022
@stale stale bot closed this Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants