GithubHelp home page GithubHelp logo

Comments (4)

fblupi avatar fblupi commented on June 13, 2024 1

I have found where is the problem. Let me better explain the context. (I will obviously anonymize the information of the users).

Giving an instance with the users below:

id name nickname email
1 John john [email protected]
2 John john2 [email protected]
3 John a.john [email protected]
4 John a.john1 [email protected]
5 John john_john [email protected]
6 John john_lennon [email protected]
7 John L. john_lucas [email protected]
8 John d.john [email protected]
9 John johndecidim [email protected]
10 John johnj [email protected]
11 John a_john_guy [email protected]

We have several users with the same name. Yes, the name can be repeated and yes, every user has a different nickname and email but let me keep explaining our problem.

Since #8524 we have been using this library: https://github.com/TarekRaafat/autoComplete.js. It's configured so it will only show a maximum of 10 results in the selector (maybe we should increase that number, but it's not a proper solution because the platform could have thousands of users, and returning all the results would be a problem too).

To include the items in the selector, we call the admin/organization/user_entities endpoint to filter the users. If we send a finding term starting with @, it will find by nickname, else it will find by email.

So... nice! I want to find the first user. If we find by name or email ("john") it will return 11 results and we'll show only 10 of them, so it's possible to not have the user we want between the items in the selector. So, let's find by email ( [email protected]). But it won't work either... why?? The complete library needs an attribute dataMatchKeys if the data received is an array of objects and it will filter by finding the term between the results too. As it's the case (we return something like: [{"id": 1, "label": "John (@john)"}, ...]) we configure this attribute with ["label"] and that's fine. But that's the reason and the root cause of our problem. Since #9791 we are not returning the email in the output of the user entities endpoint and the library won't include the result of the endpoint in the selector because it can't find [email protected] in John (@john).

To deal with this problem I have two proposals:

  • Remove the filter by email in the user entities endpoint so we won't have the problem of the endpoint returning some values the selector will never render between its items.
  • Order the results in the user entities endpoint by similarity so if we find by the full nickname, it will always return it first. So we will be able to find every user in the database by finding by full nickname.

@decidim/maintainers what do you think about it?

from decidim.

andreslucena avatar andreslucena commented on June 13, 2024

Remove the filter by email in the user entities endpoint so we won't have the problem of the endpoint returning some values the selector will never render between its items.

I think this could be problematic in other cases where we actually want to search by email:

$ rg decidim_admin.users_organization_url
decidim-conferences/app/views/decidim/conferences/admin/conference_speakers/_form.html.erb
14:          <% prompt_options = { url: decidim_admin.users_organization_url, placeholder: t(".select_user") } %>

decidim-conferences/app/views/decidim/conferences/admin/conference_invites/_form.html.erb
22:        <% prompt_options = { url: decidim_admin.users_organization_url, placeholder: t(".select_user") } %>

decidim-meetings/app/views/decidim/meetings/admin/invites/_form.html.erb
33:          <% prompt_options = { url: decidim_admin.users_organization_url, placeholder: t(".select_user") } %>

As far as I know, for meetings specially it's common tu use the invitation with the emails, as the admins may not know the nicknames/names used in the platform.

Order the results in the user entities endpoint by similarity so if we find by the full nickname, it will always return it first. So we will be able to find every user in the database by finding by full nickname.

This should be the correct behaviour IMO, if I'm searching for a value and there's an exact match then it should be the first value.

from decidim.

fblupi avatar fblupi commented on June 13, 2024

Ok, I can fix it by ordering the results by similarity and maintaining the filter by email.

Additionally, we could introduce a parameter to specify which fields (such as name, email, or nickname) we want to search within. This way, we can address this specific case without affecting other scenarios. I don't like this solution, but I have no idea how to tackle it instead.

from decidim.

andreslucena avatar andreslucena commented on June 13, 2024

@fblupi I think this can be closed as #12722 was merged. Feel free to reopen this issue if that's not the case

from decidim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.