Skip to content

Chore: Use enum for handling order_by in website and API  #73

@0ex-d

Description

@0ex-d

I suggest using BidsOrderBy enum Option<BidsOrderBy> (or generic OrderBy enum) to properly handle sorting in the api. This would in turn eliminate the need for some extra type conversions and more clarity.

pub order_by: Option<i8>,
}

if let Some(order) = filters.order() {
query.push_str(" ORDER BY block_submission.value ");
query.push_str(if order >= 0 { "ASC" } else { "DESC" });
} else {
query.push_str(" ORDER BY block_submission.slot_number DESC");
}

We can also improve the get_delivered_payloads logic by eliminating

query.push_str(if order >= 0 { "ASC" } else { "DESC" });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions