-
-
Notifications
You must be signed in to change notification settings - Fork 615
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
[IMP] mail_tracking: email score performance #299
[IMP] mail_tracking: email score performance #299
Conversation
data = self.read_group([('recipient_address', '=', email.lower())], | ||
['recipient_address', 'state'], ['state']) | ||
mapped_data = dict([(state['state'], state['state_count']) | ||
for state in data]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the surrounding [...]
brackets.
With brackets:
- Produce a lazy generator.
- Exhaust the generator converting it into a list.
- Convert the list in a dict.
Without brackets:
- Produce a lazy generator.
- Exhaust the generator converting it into a dict.
You can save tons of loops! 😊
Note that another idiomatic way (equivalent to doing it without brackets) to do so is:
mapped_data = {state['state']: state['state_count'] for state in data}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted and fixed 😉
Full coverage as well.
In instances with tons of trackings this method can resent performance. Hopefully this improves it.
cc @Tecnativa