Skip to content

Commit

Permalink
Unify the options for push notifications
Browse files Browse the repository at this point in the history
Support --platform in `push_to_users`
Support --all in `send_survey`

Testing done:
- Made the changes on the CEO server
- Sent a notification to android users
- Sent a survey to all users
  • Loading branch information
shankari committed Sep 15, 2020
1 parent 938568a commit 46001af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bin/push/push_to_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import uuid
import emission.storage.decorations.user_queries as esdu
import emission.net.ext_service.push.notify_usage as pnu
import emission.net.ext_service.push.notify_queries as pnq
import emission.core.wrapper.user as ecwu

if __name__ == '__main__':
Expand All @@ -25,14 +26,17 @@
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("-e", "--user_email", nargs="+")
group.add_argument("-u", "--user_uuid", nargs="+")
group.add_argument("-p", "--platform")
group.add_argument("-a", "--all", action="store_true")
parser.add_argument("-d", "--dev", action="store_true", default=False)

args = parser.parse_args()

if args.user_uuid:
uuid_list = [uuid.UUID(uuid_str) for uuid_str in args.user_uuid]
if args.all:
elif args.platform:
uuid_list = pnq.get_matching_user_ids(pnq.get_platform_query(args.platform))
elif args.all:
uuid_list = esdu.get_all_uuids()
else:
uuid_list = [ecwu.User.fromEmail(uuid_str).uuid for uuid_str in args.user_email]
Expand Down
4 changes: 4 additions & 0 deletions bin/push/send_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import argparse
import uuid

import emission.storage.decorations.user_queries as esdu
import emission.net.ext_service.push.notify_usage as pnu
import emission.net.ext_service.push.query.dispatch as pqd
import emission.core.wrapper.user as ecwu
Expand All @@ -27,6 +28,7 @@ def get_uuid_list_from_spec(query_spec_file):
group.add_argument("-e", "--user_email", nargs="+")
group.add_argument("-u", "--user_uuid", nargs="+")
group.add_argument("-q", "--query_spec")
group.add_argument("-a", "--all", action="store_true")

parser.add_argument("-d", "--dev", action="store_true", default=False)
parser.add_argument("-s", "--show_emails", action="store_true", default=False,
Expand All @@ -45,6 +47,8 @@ def get_uuid_list_from_spec(query_spec_file):
uuid_list = [uuid.UUID(uuid_str) for uuid_str in args.user_uuid]
elif args.user_email:
uuid_list = [ecwu.User.fromEmail(uuid_str).uuid for uuid_str in args.user_email]
elif args.all:
uuid_list = esdu.get_all_uuids()
else:
assert args.query_spec is not None
uuid_list = get_uuid_list_from_spec(args.query_spec)
Expand Down

0 comments on commit 46001af

Please sign in to comment.