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

Use different storage model for msgs #134

Merged
merged 3 commits into from
Jul 13, 2020
Merged

Conversation

paul-nameless
Copy link
Owner

@paul-nameless paul-nameless commented Jul 13, 2020

It's more comfortable to use.
It might be better when we will switch to using msg_id as current msg indicator instead of index.

tg/models.py Outdated
msg_id = msg["id"]
self.msgs[chat_id][msg_id] = msg
self.msg_ids[chat_id].append(msg_id)
self.msg_ids[chat_id].sort(reverse=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove redundant sort operations with:
if msg_id < self.msg_ids[chat_id][1]: self.msg_ids[chat_id].sort(reverse=True)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean if msg_id < self.msg_ids[chat_id][-2]:?
Cause when sorted, the biggest msg id is in the 0 index.
Or did I get something wrong?

@paul-nameless paul-nameless merged commit 39a1e59 into master Jul 13, 2020
@paul-nameless paul-nameless deleted the change-msg-storage branch July 13, 2020 12:51
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.

2 participants