Skip to content

Rust re-write dropped some metadata keys of paginated response #11

@ayalash

Description

@ayalash

From the (old) Python implementation of mailboxer

@blueprint.route("/mailboxes")
@paginated_view(renderer=_render_mailbox)
@sorted_view(allowed_fields=["last_activity", "id"])
def list_mailboxes():
    return Mailbox.query  # pylint: disable=no-member
@blueprint.route("/mailboxes/<address>/emails")
@paginated_view
def list_all_mailbox_emails(address):
    _check_mailbox_exists(address)
    return Email.query.join(Mailbox).filter(Mailbox.address == address).order_by(Email.timestamp)  # pylint: disable=no-member

While paginated_view is from weber_utils package adding the following fields to the metadata of these views: page, page_size, total_num_objects, total_num_pages

https://github.com/vmalloc/weber-utils/blob/master/weber_utils/pagination.py#L9-L32

The rust implementation is lacking these fields. For example:

[2019-11-19 17:18:39.304720] DEBUG: mailboxer.utils: [mailboxer.lab.gdc.il.infinidat.com] GET /v2/mailboxes, data: None
[2019-11-19 17:18:39.321138] DEBUG: mailboxer.utils: [mailboxer.lab.gdc.il.infinidat.com] 200 {"metadata":{"page":1},"result":[{"address":"some_address","id":1817,"last_activity":{"nanos_since_epoch":139825000, "secs_since_epoch":1574175632}}]}

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