-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Prevent promotion rule to show user multiple times #3195
Prevent promotion rule to show user multiple times #3195
Conversation
The ransack query used to fetch users for the promotion rule dropdown checked for attributes that may return repeated results. This adds the `distinct` flag in the result's call to prevent repeated records to be shown. Although this issue was seen in the promotion rule's dropdown, the bug could've been happening in different places since it lives in the resource controller.
I'm not totally sure if the approach I followed for the spec is the best one, I'd happily change it if a better approach can be accomplished |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks 🌮
We discussed this in the core meeting and we think that this is a bit too extreme as solution. 😬 If we are having multiple results there is the possibility that there are wrong table joins and it would be great to understand where is the problem and fix just that. What about going a little bit deeper and try to understand where the duplicate come from? |
@kennyadsl it is indeed! The actual source of the problem relies in the user picker javascript: solidus/backend/app/assets/javascripts/spree/backend/user_picker.js Lines 28 to 33 in a3cc823
Whit that Ransack query, the resulting pg query we obtain when giving an input
The easiest workaround I found was to just set the Do you have any suggestion? I'm happy to discuss this and update the code with whatever we come up to 😃 |
@vzqzac thanks for the detailed report! I was investigating a little bit further and I found a few things:
Let me know your thoughts. 🙂 |
Dismissing review after a past core team meeting discussion
I'm closing this since I haven't worked on it from a long time now, I'll try to open a new pull request based on @kennyadsl suggestions |
Description
The ransack query used to fetch users for the promotion rule dropdown checked for attributes that may return repeated results. This adds the
distinct
flag in the result's call to prevent repeated records to be shown.Fixes #3183
This affects the API's
ResourceController
, so the scope of the update may be wide, although the change will likely fix un-encountered issues (IMO we shouldn't be returning repeated records independently of the API call, but open to discuss)Checklist:
[ ] I have updated Guides and README accordingly to this change (if needed)