This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Remaining:
|
# Conflicts: # apps/admin_api/lib/admin_api/v1/controllers/transaction_controller.ex
Example for multiple predicates:
Edited: removed "filters" level |
unnawut
force-pushed
the
334-filtering
branch
from
September 25, 2018 09:06
4a515c1
to
1009c8a
Compare
@T-Dnzt Added |
T-Dnzt
approved these changes
Sep 27, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #334
Overview
This PR adds support for a more advanced filtering. Instead of just
search_term
andsearch_terms
, it's able to filter by conditions likeeq
(equals),neq
(not equals),lt
(less than),gte
(greater than), etc.Changes
EWallet.Web.MatchAllParser
to support filtering with all conditionsEWallet.Web.MatchAnyParser
to support filtering with any conditionsImplementation Details
This PR took inspirations from various existing open-sourced libraries but decided to write from scratch as the libraries are either very feature-rich that we use a very small subset of the feature, or very simple that it could easily be built on our existing parsers.
Also note that "match_any" is limited to 5 unique associations. This is due to the fact that Ecto supports only positional reference on joins. Named joins is coming in Ecto 3.0 but the release date is not set. So, I did a workaround by mapping the join sequence and build the dynamic query by having a fixed number of bindings (fixed to 5).
Usage
Supported comparators:
eq
,neq
,lt
,lte
,gt
,gte
,contains
andstarts_with
.For example, the attributes below will filter for confirmed transactions that came from or went to the user with username "alice".
Impact
New optional attributes:
match_all
andmatch_any
added to/transaction.all
's request format. No DB changes.