FuelLabs / fuel-indexer

*Archived* 🗃 The Fuel indexer is a standalone service that can be used to index various components of the Fuel blockchain.
140 stars 67 forks source link

enhancement: find_many order_by improvements #1485

Closed lostman closed 11 months ago

lostman commented 11 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())),
        );