Skip to content

Paginate Message APIs #34

Closed
Closed

Description

@jmattheis

Adjust APIs:

  • GET /application/{id}/message
  • GET /message

New Query Parameter:

  • limit=uint the amount of messages to return
  • since=date return all messages before this date (limited by limit)
  • since=id return all messages before the given message id

Expected Response:

{
    "paging": {
       "limit": 50,
       "next": "https://requesturl.com/message?limit=from-request&since=message-id"
    },
    "data": [
          {"id":12183,"appid":1,"message":"mymsg","title":"mytitle","priority":0,"date":"2018-03-20T19:30:51.596354+01:00"}
    ]
}

Activity

  1. lslah commented on Mar 24, 2018

    @lslah

    since=id is probably better as two messages might have the same date, see https://coderwall.com/p/lkcaag/pagination-you-re-probably-doing-it-wrong

  2. jmattheis commented on Mar 24, 2018

    @jmattheis
    MemberAuthor

    @lslah Using ids for pagination seems to be better. Good point!

  3. self-assigned this
    on Apr 8, 2018
  4. added 9 commits that reference this issue on Apr 13, 2018
  5. added 9 commits that reference this issue on Apr 13, 2018
  6. naimo commented on Jun 15, 2020

    @naimo

    The name of the parameter seems weird to me : message ids get incremented, so the message received by the server "since" a given id are those with higher numbers.

    Keeping the current behavior, the parameter should be renamed "until" or "before". Better though would be to keep "since" but actually return new messages. Seems to be a more frequent use case no ?

  7. jmattheis commented on Jun 15, 2020

    @jmattheis
    MemberAuthor

    @naimo Naming is hard (:.

    I think, I called it this way because the messages are sorted in descending order. Thus, since kinda makes sense. The behavior is also documented

    Ascending:
    Message 1 |- until 3
    Message 2 |
    Message 3
    Message 4 | 
    Message 5 |- since 3
    
    Descending:
    Message 5 |- until 3
    Message 4 |
    Message 3
    Message 2 | 
    Message 1 |- since 3
    

    I don't think this renaming would justify a breaking API change.

    Better though would be to keep "since" but actually return new messages. Seems to be a more frequent use case no ?

    It is actually not because new messages will be transmitted via web socket. Still, the API addition would have some use cases.

  8. naimo commented on Jun 15, 2020

    @naimo
  9. jmattheis commented on Jun 15, 2020

    @jmattheis
    MemberAuthor

    @naimo Yeah, our android app does something similar. I've created #329 to add this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions