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

More versatile user search functionality #6024

Open
moschlar opened this issue Apr 18, 2024 · 1 comment
Open

More versatile user search functionality #6024

moschlar opened this issue Apr 18, 2024 · 1 comment

Comments

@moschlar
Copy link
Contributor

Since we're having quite a huge amount of users from different institutions, the need for more advances user search functionality has arisen!

Specifically, a user asked whether searching for a user in the sharing dialog (and thereby using the search-user API) can be augmented to also search in the institution field.

Now I understand that it might be difficult to simply use all words from the search query string to also search for institutions as that would be kind of fuzzy.
Maybe a more easy and useful solution would be to simply add a checkbox to toggle whether to search users only in the own institution (or a selection listing all available institutions?)?


From the admin side of things, I would like to have a configurable option to specify how many results the search function shall return (currently hardcoded to 10).


FWIW, as a small workaround for convenience, I added the following custom function, which tries to at least sort the list such that users from the own institution (or having the same email domain) are listed first:

def custom_search_user(request, emails):
    emails_front, emails_back = [], []

    institution_name = ''

    username = request.user.username
    user_domain = username.split('@', 1)[1]
    profile = Profile.objects.get_profile_by_user(username)
    if profile:
        institution_name = profile.institution

    for email in emails:
        email_domain = email.split('@', 1)[1]
        if email_domain == user_domain:
            emails_front.append(email)
        else:
            p = Profile.objects.get_profile_by_user(email)
            logger.debug(f'{email=} {p=}')
            if p and p.institution and institution_name in p.institution:
                emails_front.append(email)
            else:
                emails_back.append(email)

    logger.debug(f'{emails_front=} {emails_back=}')
    return emails_front + emails_back
@freeplant
Copy link
Member

From the admin side of things, I would like to have a configurable option to specify how many results the search function shall return (currently hardcoded to 10)

When we design the feature, we think there will not be too many people with same name. When a user refine the search characters, there should be less and less people matching. So I think 10 is enough. If it does meet your case, please send us more information regarding the issue.

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

No branches or pull requests

2 participants