Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pagination to ListAllOrganizations API #724

Merged

Conversation

AmanGIT07
Copy link
Contributor

@AmanGIT07 AmanGIT07 commented Aug 14, 2024

Overview:

A new package named pagination is introduced. It has methods like Offset and SetTotalPages which will be useful in API that needs pagination.
ListAllOrganizations uses this and returns x amount of records by default. The page number and items per page can be modulated by params: page_num & page_size respectively. The API response includes count denoting the total number of records.

Testing:

  1. Default behaviour

Request:

`curl --location 'http://localhost:8400/frontier-api/v1beta1/admin/organizations' \
--header 'Cookie: sid=`

Response:

`{
    "organizations": [
        {
            "id": "",
            "name": "",
            "title": "",
            "metadata": {},
            "created_at": "",
            "updated_at": "",
            "state": "",
            "avatar": ""
        },
        {
            "id": "",
            "name": "",
            "title": "",
            "metadata": {},
            "created_at": "",
            "updated_at": "",
            "state": "",
            "avatar": ""
        }
    ],
    "count": 2
}`
  1. Request a specific page with page size

Request:

curl --location 'http://localhost:8400/frontier-api/v1beta1/admin/organizations?page_num=1&page_size=10' \
--header 'Cookie: sid='

Response:

{
    "organizations": [
        {
            "id": "",
            "name": "",
            "title": "",
            "metadata": {},
            "created_at": "",
            "updated_at": "",
            "state": "",
            "avatar": ""
        }
    ],
    "count": 2
}
  1. Use pagination with existing filter

Request:

curl --location 'http://localhost:8400/frontier-api/v1beta1/admin/organizations?state=disabled&page_num=1&page_size=1' \
--header 'Cookie: sid='

Response:

{
    "organizations": [
        {
            "id": "",
            "name": "",
            "title": "",
            "metadata": {},
            "created_at": "",
            "updated_at": "",
            "state": "disabled",
            "avatar": ""
        }
    ],
    "count": 1
}

Copy link

vercel bot commented Aug 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontier ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 21, 2024 4:09pm

@coveralls
Copy link

coveralls commented Aug 14, 2024

Pull Request Test Coverage Report for Build 10493450561

Details

  • 49 of 82 (59.76%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 9.383%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/store/postgres/organization_repository.go 13 17 76.47%
proto/v1beta1/admin.pb.go 8 15 53.33%
proto/v1beta1/admin.pb.validate.go 0 22 0.0%
Totals Coverage Status
Change from base Build 10486587305: 0.04%
Covered Lines: 10195
Relevant Lines: 108657

💛 - Coveralls

core/pagination/pagination.go Outdated Show resolved Hide resolved
core/pagination/pagination.go Outdated Show resolved Hide resolved
@AmanGIT07 AmanGIT07 merged commit f8b2125 into main Aug 22, 2024
7 checks passed
@AmanGIT07 AmanGIT07 deleted the feature/ide-530-paginationadmin-list-organizations-api branch August 22, 2024 06:33
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.

3 participants