-
Notifications
You must be signed in to change notification settings - Fork 25
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
RFC: Custom filters and orderings #1868
Comments
I like the proposal, and I think we could handle the impact of varying schemas 👍 |
I do like the idea, but I see two primary issues that we need to solve:
Regarding the Python APIThe current settings.CUSTOM_FILTERS = {
"Question": {
"customFilter": "myapp.caluma.custom_filters.my_custom_question_filter"
},
"Case": {
"anotherFilter": "myapp.caluma.custom_filters.my_custom_case_filter",
"oneMore": "myapp.caluma.custom_filters.one_more_filter"
}
} Regarding the type systemI suggest adding a few "simple" base filtes to use that extend the existing For more complex filters, I suggest providing a "generic" input type where we don't enforce an exact syntax: Just pass in a piece of JSON, similar to the This won't keep implementors from adding their own input types if they really need, but we should strive to make the normal case as simple as possible |
Description of the problem
Caluma defines a fix set of filters and orderings for each graph in our schema. If an implementing app requires an extension of said fix sets, most of the time it can be implemented in the core. However, there are use-cases in which it doesn't make sense to put it into the core because it would be too complex to implement it dynamically enough to be in the core of Caluma.
For instance: let's say we want to filter all cases that have an answer (date)
"decision-date"
on a document on a work item of the task"decision"
but only if that work item is completed.To implement this in the core, a massively complex extension of the
hasAnswer
orsearchAnswer
filter would be necessary, for a filter that could be solved with a very basic custom implementation:If such custom filters would be allowed by the Caluma core, we'd have a method to not unnecessarily make the core too complex and still be able to implement the needed features. This RFC proposes an extension of the API to allow custom filters and orderings.
Possible solutions
Option A
Caluma allows two new extension setting
CUSTOM_FILTER_CLASSES
andCUSTOM_ORDERING_CLASSES
. Those should be defined as a dict which keys are the existing filterset / orderset classes that should be extended and a string which holds the location of the custom filterset / orderset class:Which would result in a value of
Now, this would then generate a new parameter
customFilter
for all graphs using theQuestionFilterSet
orCaseFilterSet
:There is already a proof of concept of this implementation here: #1867
Option B
Configuration would be the same as in option a but the custom filters would be merged into the existing filter parameter. This option would result in a slimmer schema but it brings more technical problems such as colliding filters etc. Also, I'm not 100% sure that this would even be possible since the
filter
/order
parameter currently needs one backing filterset / orderset class.The API usage would look like this:
Pros / cons
The text was updated successfully, but these errors were encountered: