Skip to content

Conversation

@stellenberger
Copy link
Contributor

@stellenberger stellenberger commented Apr 10, 2023

this adds pagy gem to the mix with pagination onto the following endpoints:

v2 learning resources
v2 campaigns
v2 campaign actions
v1 articles

you can add custom page size using the page_size={your_custom} to the query params

default page size if it is not specified will be 25

metadata about next and prev urls are stored in the json object named pagination_metadata that can be found in the response

example response

{
    "data": [
        {
            "id": 1,
            "title": "rubber meets the road",
            "time": 0.1,
            "link": "http://waters.net/nathan.jacobson",
            "type": "",
            "learning_topic_id": 1,
            "created_at": "2022-08-09T08:55:51.094Z",
            "updated_at": "2022-08-09T08:55:51.094Z",
            "source": "",
            "release_date": "2022-03-19T00:00:00.000Z",
            "end_date": "2022-09-26T00:00:00.000Z",
            "causes": [
                {
                    "id": 32,
                    "image": "http://homenick-schultz.org/lilliam",
                    "icon": "http://goodwin-pfeffer.biz/krystal.corkery",
                    "name": "thought leader",
                    "description": "Vel aperiam sint quod.",
                    "joiners": 4,
                    "created_at": "2022-08-09T08:55:51.104Z",
                    "updated_at": "2022-08-09T08:55:51.104Z",
                    "joined": false
                }
            ],
            "completed": false
        },
        {
            "id": 2,
            "title": "agile marketing",
            "time": 0.1,
            "link": "http://daniel-senger.name/ginger.jakubowski",
            "type": "",
            "learning_topic_id": 2,
            "created_at": "2022-08-09T08:55:51.127Z",
            "updated_at": "2022-08-09T08:55:51.127Z",
            "source": "",
            "release_date": "2022-04-09T00:00:00.000Z",
            "end_date": "2022-11-28T00:00:00.000Z",
            "causes": [
                {
                    "id": 34,
                    "image": "http://moen.org/hal.mohr",
                    "icon": "http://bartoletti-crist.net/franklyn_green",
                    "name": "bandwidth-constrained",
                    "description": "Expedita exercitationem accusamus quia.",
                    "joiners": 83,
                    "created_at": "2022-08-09T08:55:51.133Z",
                    "updated_at": "2022-08-09T08:55:51.133Z",
                    "joined": false
                }
            ],
            "completed": false
        }
    ],
    "pagination_metadata": {
        "count": 5,
        "page": 1,
        "pages": 3,
        "next": 2,
        "prev": null,
        "next_url": "http://localhost:3000/api/v2/learning_resources?page=2&page_size=2",
        "prev_url": "http://localhost:3000/api/v2/learning_resources?page_size=2"
    }
}

@stellenberger stellenberger force-pushed the add-pagination-to-endpoints branch from cf03987 to 656c87d Compare April 18, 2023 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants