Skip to content

Commit 6e8320f

Browse files
committed
Fix event attendees capping at roughly 750
1 parent 6903c49 commit 6e8320f

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "recnetpy"
7-
version = "0.2.70"
7+
version = "0.2.71"
88
authors = [
99
{ name="RecNetBot Development"}
1010
]

src/recnetpy/dataclasses/event.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from .base import BaseDataClass
44
from .event_response import EventInteraction
5-
from ..misc import date_to_unix
5+
from ..misc import date_to_unix, list_chunks
66
from ..misc.constants import ACCESSIBILITY_DICT
77

88
if TYPE_CHECKING:
@@ -170,6 +170,21 @@ async def resolve_responders(self, force: bool = False) -> List['EventInteractio
170170
player = self.client.accounts.create_dataclass(response.player_id)
171171
response.player = player
172172
players[response.player_id] = player
173-
data: 'Response[List[AccountResponse]]' = await self.rec_net.accounts.bulk.make_request('post', body = {"id": players.keys()})
174-
for data_response in data.data: players.get(data_response['accountId']).patch_data(data_response)
173+
174+
player_ids = list(players.keys())
175+
data: List[AccountResponse] = []
176+
177+
# 750 == roughly 9750 bytes of payload
178+
# limit of 10240 bytes in API
179+
if len(player_ids) > 750:
180+
player_chunks = list_chunks(player_ids, 750)
181+
for i in player_chunks:
182+
response: 'Response[List[AccountResponse]]' = await self.rec_net.accounts.bulk.make_request('post', body = {"id": i})
183+
data += response.data
184+
else:
185+
# Fits in a single payload
186+
response: 'Response[List[AccountResponse]]' = await self.rec_net.accounts.bulk.make_request('post', body = {"id": player_ids})
187+
data = response.data
188+
189+
for data_response in data: players.get(data_response['accountId']).patch_data(data_response)
175190
return self.responses

src/recnetpy/misc/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .bitmask_decode import bitmask_decode
22
from .date_to_unix import date_to_unix
33
from .variable_class import VariableClass
4-
from .stringify_bulk import stringify_bulk
4+
from .stringify_bulk import stringify_bulk
5+
from .chunks import list_chunks

src/recnetpy/misc/chunks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def list_chunks(lst, n):
2+
"""Yield successive n-sized chunks from lst."""
3+
for i in range(0, len(lst), n):
4+
yield lst[i:i + n]

0 commit comments

Comments
 (0)