-
Notifications
You must be signed in to change notification settings - Fork 2
Add multi-send #84
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
Add multi-send #84
Conversation
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.
Minor comments
rapid_pro_tools/rapid_pro_client.py
Outdated
log.info(f"Sending a message to {len(urns)} URNs...") | ||
log.debug(f"Sending to {urns}...") | ||
batch = [] | ||
ids = [] |
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.
ids = [] | |
broadcast_ids = [] |
I read this as contact ids at first
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.
Good point, thanks
rapid_pro_tools/rapid_pro_client.py
Outdated
interrupted += len(batch) | ||
log.info(f"Interrupted {interrupted} / {len(urns)} URNs") | ||
|
||
response: Broadcast = self.rapid_pro.create_broadcast(message, urns=batch) |
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.
I wonder if we should remove the : Broadcast to avoid future confusion, as we're not using type hinting anywhere else
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.
Will do
rapid_pro_tools/rapid_pro_client.py
Outdated
log.info(f"Interrupted {interrupted} / {len(urns)} URNs") | ||
log.info(f"Sent {sent} / {len(urns)} URNs") |
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.
Maybe push these into the if to avoid double printing e.g. 200/200 if the number of requested urns is divisible by 100
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.
Good catch, thanks!
Co-authored-by: Alexander Simpson <[email protected]>
Co-authored-by: Alexander Simpson <[email protected]>
Co-authored-by: Alexander Simpson <[email protected]>
@as2388 I'd like to add something like this to the code. The testing is going to be pretty laborious - so if you could take a look at the direction to see if you want something different before I start testing that would be great.
I've written it on the basis that we might want to deprecate and remove the 'send to single' API which will make it consistent with the interrupt API we surface.
If you're ok with this, I'll send you a proper PR after I'm done with testing and any changes needed