FuelLabs / fuel-indexer

🗃 The Fuel indexer is a standalone service that can be used to index various components of the Fuel blockchain.
https://docs.fuel.network/docs/indexer/
140 stars 66 forks source link

enhancement: find_many order_by improvements #1485

Closed lostman closed 8 months ago

lostman commented 8 months ago

Issue

After looking at the examples @ra0x3 added to the release notes:

https://github.com/FuelLabs/fuel-indexer/releases/tag/v0.24.0

I realized the implementation of order_by doesn't match the SQL.

The desired DSL should look like this:

        let found_order = Order::find(
            Order::amount()
                .gt(order.amount)
                .and(Order::address().eq(0x001))
                .order_by(Order::time().asc()),
        );

Meanwhile, the current implementation is like this:

        let found_order = Order::find(
            Order::amount()
                .gt(order.amount)
                .and(Order::address().eq(0x001))
                .order_by(Order::time()).asc(),
        );

Furthermore, the results can currently be ordered only by a single field.

I will update the DSL to match SQL, and add an ordering by multiple fields:

        let found_order = Order::find(
            Order::amount()
                .gt(order.amount)
                .and(Order::address().eq(0x001))
                .order_by((Order::time(), Order::amount().desc())),
        );