Skip to content

Commit 3eec0c3

Browse files
authored
Merge pull request #603 from python-discord/decrease-batch-size-for-user-list-endpoint
Decrease page size for user list endpoint.
2 parents 5985beb + 4c527e7 commit 3eec0c3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pydis_site/apps/api/tests/test_users.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .base import AuthenticatedAPITestCase
77
from ..models import Role, User
88
from ..models.bot.metricity import NotFoundError
9+
from ..viewsets.bot.user import UserListPagination
910

1011

1112
class UnauthedUserAPITests(AuthenticatedAPITestCase):
@@ -357,7 +358,7 @@ class UserPaginatorTests(AuthenticatedAPITestCase):
357358
@classmethod
358359
def setUpTestData(cls):
359360
users = []
360-
for i in range(1, 10_001):
361+
for i in range(1, UserListPagination.page_size + 1):
361362
users.append(User(
362363
id=i,
363364
name=f"user{i}",
@@ -373,9 +374,10 @@ def test_returns_single_page_response(self):
373374
self.assertIsNone(response["previous_page_no"])
374375

375376
def test_returns_next_page_number(self):
377+
user_id = UserListPagination.page_size + 1
376378
User.objects.create(
377-
id=10_001,
378-
name="user10001",
379+
id=user_id,
380+
name=f"user{user_id}",
379381
discriminator=1111,
380382
in_guild=True
381383
)
@@ -384,9 +386,10 @@ def test_returns_next_page_number(self):
384386
self.assertEqual(2, response["next_page_no"])
385387

386388
def test_returns_previous_page_number(self):
389+
user_id = UserListPagination.page_size + 1
387390
User.objects.create(
388-
id=10_001,
389-
name="user10001",
391+
id=user_id,
392+
name=f"user{user_id}",
390393
discriminator=1111,
391394
in_guild=True
392395
)

pydis_site/apps/api/viewsets/bot/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class UserListPagination(PageNumberPagination):
2020
"""Custom pagination class for the User Model."""
2121

22-
page_size = 10000
22+
page_size = 2500
2323
page_size_query_param = "page_size"
2424

2525
def get_next_page_number(self) -> typing.Optional[int]:

0 commit comments

Comments
 (0)