-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add new filtering API endpoint #1061
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1061 +/- ##
==========================================
+ Coverage 92.70% 92.74% +0.04%
==========================================
Files 108 111 +3
Lines 3852 3985 +133
==========================================
+ Hits 3571 3696 +125
- Misses 281 289 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Looks good overall, thanks @dmos62.
Reading through this PR, I think we should rename the mathesar_types
concept to ui_types
instead - that way, they match the nomenclature of the API and it's clearer that they are UI abstractions.
I'm also wondering whether it makes sense to separate the parameters for the value being filtered (the first parameter) from the parameters that are part of the filtering function (the second and onwards). I think it would make the API clearer to use without accompanying documentation. I'm thinking something like:
{
"id": "greater",
"display_name": "is greater than",
"accepts": [
{
"display_name": "value",
"ui_types": [
"number"
]
},
]
"filter_parameters": [
{
"display_name": "value",
"ui_types": [
"number"
]
}
]
},
Please note a couple of other changes:
- I renamed
name
todisplay_name
to make it clearer that it's to be used for display. - I also added a
display_name
attribute to parameters that the frontend can use as a placeholder. This may be unnecessary, I defer to @pavish.
@kgodey I'm not sure. Notice that As seen in the next filtering PR, the frontend uses the function API to submit filters to the backend, whose format is a sequence of parameters: I think it should be up to the UI-builder to decide what is the primary parameter. At the moment, I'm just making sure the order of parameters is what you'd expect. If more complicated signatures are ever needed, we can give parameters display names to remove ambiguity for the user. Does this make sense? |
By the way, I'll rename |
This is not necessary at the moment since the parameters are currently accepted as an array and referenced by position, instead of an object where they are referenced by name (As mentioned in #1069). If & when we transform that in the future, the frontend will need a name for each parameter to form the request. Edit: @dmos62 has the same comment in #1061 (comment) |
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.
@dmos62 It seems like you've forgotten to update the mathesar_types
key in the test. Please fix the test and merge this PR.
I'm fine with the positional parameters, thanks for the explanation. I'm still wary of using array positions to implicitly determine what's being filtered and what it's being filtered against, but we can solve that problem if/when it becomes a problem.
Adds the new filtering API endpoint
/api/ui/v0/databases/1/filters/
; but, does not replace the current filtering API: that will come in a subsequent PR. Includes the foundational logic that introduces the new endpoint and declares through it what the valid filters are for which Mathesar types.This PR can be seen as adding the read aspect of the new filtering API, while the next one will add the write aspect (i.e. actually filtering with it).
This filtering API revamp is split into multiple PRs so as to make reviewing easier.
Also, introduces filters for the Mathesar number type (#385).
Technical details
The new endpoint's response looks like this:
To single out one of the filters:
This says that the
is greater than
filter takes two parameters and both of them should be Mathesar numbers.Things to note:
lesser_or_equal
(combination oflesser
andequal
);uri_authority_contains
);name
attribute is meant to be used in ax {name} y
type of scenarios, likex is lesser than y
;parameters
attribute declares the Mathesar type of each parameter used by filter;and
,or
,not
: those will have to be hardcoded on the frontend (like it currently is with SA filters);Checklist
Update index.md
).master
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin