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

Improve efficiency and UX of unique reactions checks #113

Open
eibex opened this issue Feb 17, 2023 · 1 comment
Open

Improve efficiency and UX of unique reactions checks #113

eibex opened this issue Feb 17, 2023 · 1 comment
Labels
enhancement Software improvement

Comments

@eibex
Copy link
Owner

eibex commented Feb 17, 2023

Currently, for each reaction a message has we are checking all users who reacted to it.
This is extremely slow on messages with many reactions and/or people who reacted to them.

A possible solution could be to cache reactions, however, it could lead to problems if the DB isn't in sync anymore due to manual changes, outages, errors, etc.

for existing_reaction in msg.reactions:
if str(existing_reaction.emoji) == reaction:
continue
reaction_users = await existing_reaction.users().flatten()
reaction_users_ids = (reaction_user.id for reaction_user in reaction_users)
if user_id in reaction_users_ids:
await msg.remove_reaction(existing_reaction, user)
# We can safely break since a user can only have one reaction at once
break

@eibex eibex added the enhancement Software improvement label Feb 17, 2023
@eibex
Copy link
Owner Author

eibex commented Apr 9, 2023

Potential solution could be to check user roles instead of each reaction (and each user per reaction) and try to remove the associated reaction (assuming it wasn't manually added).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Software improvement
Projects
None yet
Development

No branches or pull requests

1 participant