Improve speed of stories parsing

This commit is contained in:
KurimuzonAkuma 2023-11-09 11:43:57 +03:00
parent dcdf65ebf3
commit 2bbe5af50b
4 changed files with 20 additions and 8 deletions

View File

@ -56,12 +56,15 @@ class GetAllStories:
)
)
users = {i.id: i for i in r.users}
chats = {i.id: i for i in r.chats}
for peer_story in r.peer_stories:
for story in peer_story.stories:
yield await types.Story._parse(
self,
story,
{i.id: i for i in r.users},
{i.id: i for i in r.chats},
users,
chats,
peer_story.peer
)

View File

@ -59,11 +59,14 @@ class GetPeerStories:
)
)
users = {i.id: i for i in r.users}
chats = {i.id: i for i in r.chats}
for story in r.stories.stories:
yield await types.Story._parse(
self,
story,
{i.id: i for i in r.users},
{i.id: i for i in r.chats},
users,
chats,
r.stories.peer
)

View File

@ -69,13 +69,16 @@ class GetStories:
stories = []
users = {i.id: i for i in r.users}
chats = {i.id: i for i in r.chats}
for story in r.stories:
stories.append(
await types.Story._parse(
self,
story,
{i.id: i for i in r.users},
{i.id: i for i in r.chats},
users,
chats,
peer
)
)

View File

@ -77,12 +77,15 @@ class GetStoriesArchive:
last = r.stories[-1]
offset_id = last.id
users = {i.id: i for i in r.users}
chats = {i.id: i for i in r.chats}
for story in r.stories:
yield await types.Story._parse(
self,
story,
{i.id: i for i in r.users},
{i.id: i for i in r.chats},
users,
chats,
peer
)