Skip to content
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

[Feature Request]: Filtering support for my_recent_swaps #784

Closed
Milerius opened this issue Dec 29, 2020 · 2 comments
Closed

[Feature Request]: Filtering support for my_recent_swaps #784

Milerius opened this issue Dec 29, 2020 · 2 comments
Assignees

Comments

@Milerius
Copy link

Milerius commented Dec 29, 2020

Is your feature request related to a problem? Please describe.

Since #780 and #781 we page pagination support ! 🎊

However it includes other problems, like filtering, indeed filtering only applies on the result of the pagination that based on the initial request my_recent_swaps.

The problem is that if we have for example 220 swaps, with a limit of 50swaps per pages, we have 5 pages (without filtering) but if we do filtering the total number of swaps changes and the number of pages also changes. (not supported my mm2 yet)

This need to be handled in mm2 side.

Describe the solution you'd like

I wish the rpc call my_recent_swaps could take an optional new filtering parameter.

//! 1st example (Returns 50 first swaps for page 1 that are between `1609223333` and `1609225294`)
{
  "userpass": "rpc_password",
  "method": "my_recent_swaps",
  "page_number": 1,
  "limit": 50,
  "filtering": {"date_range": [1609223333, 1609225294]}
}

//! 2nd example  (Returns 50 first swaps for page 1 that have base_coin `RICK` and that are between `1609223333` and `1609225294`)
{
  "userpass": "rpc_password",
  "method": "my_recent_swaps",
  "page_number": 1,
  "limit": 50,
  "filtering": {"date_range": [1609223333, 1609225294], "pattern": "RICK/*" }
}

//! 3rd example (Returns 50 first swaps for page 1 that have base_coin `RICK`)
{
  "userpass": "rpc_password",
  "method": "my_recent_swaps",
  "page_number": 1,
  "limit": 50,
  "filtering": {"pattern": "RICK/*" }
}

Note that total_pages in the answer should also change based on the filtering.

Describe alternatives you've considered

Fetch all the swaps once, and then apply filtering myself, but with huge swaps history this cost too much memory and this is slow

Additional context

Maybe related to the fact that MM2 plan to move DB to smth like: embedded DB like SQLite, will be easier to use filtering in this case

Also related to KomodoPlatform/komodo-wallet#621

Video: https://user-images.githubusercontent.com/21139416/103265567-32c76e80-49ae-11eb-94ce-8b39dfe27385.mov

@artemii235 artemii235 self-assigned this Jan 13, 2021
artemii235 added a commit that referenced this issue Jan 28, 2021
* WIP. Try rusqlite crate.

* WIP. Try rusqlite crate.

* WIP. Fix clippy.

* WIP. Added SQLite DB init and migration. TODO: insert swaps data into DB.

* WIP. Indexed existing swaps to SQLite on DB migration.

* WIP. Insert new started swaps data to SQLite.

* WIP. Added SQL selection of uuids depending on MyRecentSwapsReq.

* WIP. Refactor recent swaps uuids select to named params.

* Added from_uuid support for SQLite. Refactoring. Feature finished.

* Remove +nightly from cargo commands.

* Fixes after review.

* Set page_number to 1 in my_recent_swaps response
when page_number and from_uuid are not set in request.
@artemii235
Copy link
Member

I have implemented the filtering: the params are passed a bit differently than requested, but I think it looks a bit more straight-forward this way. The corresponding PR has been just merged, the docs update PR will be merged soon and published on the website.

@artemii235
Copy link
Member

The Github release has been just published: https://github.com/KomodoPlatform/atomicDEX-API/releases/tag/beta-2.1.2978. All OS builds will be uploaded from CI quite soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants