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

Use fuse.js to filter and rank users by username and full_name fields in PaginatedListContainer #7735

Merged

Conversation

jonboiser
Copy link
Contributor

Summary

  1. Reimplements and renames the filterAndSortUsers (at kolibri.utils.filterUsersByNames) utility using fuse.js library.
  2. Removes duplicated code across different Kolibri plugins and move the filtering logic into PaginatedListContainer
  3. Change the textbox filter in PaginatedListContainer such that the textbox is refocused after the user clears is by clicking the "X" button

Reviewer guidance

  1. Based on how fuse.js is configured, exact word matches should display first in user search #7131 is resolved because it will give exact matches between the filter's input and a user's full name or username the top rank in the results.
  2. Non-exact matches will also be ranked and filtered within the configured threshold of "0.1", which is intended to not be forgiving of large difference between the filter and the users' names.

References

Fixes #7131


Contributor Checklist

PR process:

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Testing:

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

Reviewer Checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@jonboiser jonboiser added TODO: needs review Waiting for review changelog Important user-facing changes labels Jan 8, 2021
@jonboiser jonboiser added this to the 0.14.6 milestone Jan 8, 2021
@codecov
Copy link

codecov bot commented Jan 9, 2021

@jonboiser jonboiser changed the title Use fuse.js to filter and rank username and full_name fields in PaginatedListContainer Use fuse.js to filter and rank users by username and full_name fields in PaginatedListContainer Jan 9, 2021
@jonboiser jonboiser force-pushed the sort-exact-user-matches branch from 7ce4ebe to cd9d5e1 Compare January 14, 2021 18:31
@jonboiser jonboiser modified the milestones: 0.14.6, 0.14.7, 0.14.8 Jan 20, 2021
Comment on lines -195 to +214
redirectBrowser,
branding,
browserInfo,
bytesForHumans,
CatchErrors,
contentNode,
coreBannerContent,
exams,
validators,
serverClock,
filterUsersByNames,
i18n,
licenseTranslations,
loginComponents,
navComponents,
coreBannerContent,
redirectBrowser,
samePageCheckGenerator,
CatchErrors,
UserType,
shuffled,
bytesForHumans,
branding,
scriptLoader,
serverClock,
shuffled,
sortLanguages,
UserType,
validators,
Copy link
Member

Choose a reason for hiding this comment

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

Just gotta say I love that you sorted this list.

Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

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

Tested and it worked perfectly. Great work!

@jonboiser jonboiser merged commit fc57aeb into learningequality:release-v0.14.x Feb 26, 2021
@jonboiser jonboiser deleted the sort-exact-user-matches branch February 26, 2021 20:08
@jonboiser jonboiser removed the TODO: needs review Waiting for review label Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Important user-facing changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exact word matches should display first in user search
2 participants