iroha icon indicating copy to clipboard operation
iroha copied to clipboard

[feature] #2553: Add sorting to queries

Open pesterev opened this issue 3 years ago • 4 comments

Signed-off-by: Vladimir Pesterev [email protected]

Description of the Change

I've added sorting parameter into ISI queries.

The sorting will apply only to entities that have metadata.

More about here.

  • [x] Minimal representation of this feature.
  • [x] Implement for all queries.
  • [x] More tests.

Issue

Resolves #2553

Benefits

Allows to sort the result of queries

Possible Drawbacks

None.

pesterev avatar Aug 01 '22 12:08 pesterev

Codecov Report

Merging #2575 (533af1d) into iroha2-dev (a16d9c3) will decrease coverage by 2.15%. The diff coverage is 64.79%.

:exclamation: Current head 533af1d differs from pull request most recent head 0d4ae2d. Consider uploading reports for the commit 0d4ae2d to get more accurate results

@@              Coverage Diff               @@
##           iroha2-dev    #2575      +/-   ##
==============================================
- Coverage       67.61%   65.45%   -2.16%     
==============================================
  Files             140      157      +17     
  Lines           26173    28303    +2130     
==============================================
+ Hits            17696    18526     +830     
- Misses           8477     9777    +1300     
Impacted Files Coverage Δ
cli/derive/src/lib.rs 74.72% <ø> (ø)
cli/src/torii/mod.rs 28.88% <ø> (ø)
client_cli/src/main.rs 0.26% <ø> (ø)
config/base/src/runtime_upgrades.rs 35.63% <ø> (ø)
core/src/block.rs 70.00% <ø> (ø)
core/src/queue.rs 95.67% <ø> (-0.08%) :arrow_down:
core/src/smartcontracts/isi/asset.rs 54.82% <ø> (ø)
core/src/sumeragi/message.rs 8.20% <0.00%> (ø)
core/src/sumeragi/mod.rs 0.00% <ø> (ø)
core/test_network/src/lib.rs 28.81% <0.00%> (-19.17%) :arrow_down:
... and 161 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Aug 01 '22 14:08 codecov[bot]

@mversic

  1. Depends on prioritization. Currently, it seems we don't have the resources for that.
  2. I suppose that the right decision is to add a middleware that will sort the results of queries by specific parameters and cache them. The current decision is temporary and makes it possible to use the sorting feature.

pesterev avatar Aug 02 '22 08:08 pesterev

@appetrosyan I've moved the sorting to torii handler but it sorts only assets-related queries.

pesterev avatar Aug 03 '22 09:08 pesterev

@appetrosyan

These should be extracted into their own query crate: Pagination, Predicate, Sorting and the queries themselves.

The suggestion to move queries to a separate crate looks non-trivial, and I think it will be done in a new issue.

pesterev avatar Aug 08 '22 08:08 pesterev