-
Notifications
You must be signed in to change notification settings - Fork 49
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
[*] Smart Segments - Prevent includes from queryBuilder to overwrite include from segment scope #179
base: main
Are you sure you want to change the base?
Conversation
services/resources-getter.js
Outdated
model.unscoped().count(countOpts), | ||
model.unscoped().findAll(findAllOpts) | ||
]); | ||
} |
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.
Thanks for the refactoring ;)
I applied it on the latest code version here: a1cc888
Hi @louisremi, the current segment feature has been implemented to filter the records to retrieve and not to customize the aggregation done on the retrieved data. I am not sure to understand your use case here. Thanks for your help. |
@arnaudbesnier We use this patch to display aggregated info from different tables in list views. The only alternative is to use a "View as Model", (e.g. https://github.com/chez-nestor/backoffice/blob/master/src/models/AmountView.js ) but this is often overkill. |
…ude from segment scope
81db740
to
43caa10
Compare
@arnaudbesnier done! Looking forward to your review, as this is the last patch we have to backport everytime we want to update our Liana :-) |
660dc77
to
9f305b9
Compare
Considering three models
City
,Region
,Country
, their associations, and the scope and collection defined as follows:When requesting the segment
with country
, the current implementation of resources-getter.js would return the city and the associated region, but not the country associated to that region. This is becauseRegion
is added automatically to the.include
list of the request, and overwrites theRegion
included in the scope.This patch prevents includes returned by queryBuilder.getIncludes to overwrite the includes of the scope.