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 peer_story in r.peer_stories:
for story in peer_story.stories: for story in peer_story.stories:
yield await types.Story._parse( yield await types.Story._parse(
self, self,
story, story,
{i.id: i for i in r.users}, users,
{i.id: i for i in r.chats}, chats,
peer_story.peer 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: for story in r.stories.stories:
yield await types.Story._parse( yield await types.Story._parse(
self, self,
story, story,
{i.id: i for i in r.users}, users,
{i.id: i for i in r.chats}, chats,
r.stories.peer r.stories.peer
) )

View File

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

View File

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