Comments (4)
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 | |
---|---|---|---|
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.
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.
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.
@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)
- undefined method error of `NoMethodError in Decidim::Assemblies::Assemblies#show` HOT 1
- When replying to a comment, it auto-closes while typing
- Conference registering is broken when no registration_types HOT 1
- Internal Server Error 500 when trying to create a new conference or initiative HOT 2
- Error on admin Assemblies Edit HOT 2
- The user can update a meeting with empty body
- The user can create a meeting even if its body contains only capital letters or is not starting with a capital letter HOT 1
- The body error message from proposal creation form is not displayed according to the text inside the field
- Downloading open data files does not work properly or does not work at all
- Server error in Accountability component when associating categories
- Admin dropdown menu's actionable area is not what the user expects
- Emoji-mart increases the decidim_core bundle size significantly
- Enable viewing proposals in grid mode HOT 4
- Fix subject in `close_meeting_reminder` string
- The service worker cache is causing hard to debug issues mainly in production environments HOT 1
- Rename ```populate_help.rb``` to ```static_pages_seeds.rb``` HOT 2
- Organization SMTP change setting got 500 error HOT 4
- The user's tooltip is not displayed anymore after clicking on the Like/Dislike button from Proposal details page
- At admin creation, using the email address as name does pop up an error but still creates the tenant (without the admin) HOT 2
- Deleted private user from private assembly still follows assembly and its components
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from decidim.