From 938568ace7d8aa873181114d4c1f49c76efb8b55 Mon Sep 17 00:00:00 2001 From: Shankari Date: Mon, 14 Sep 2020 20:45:46 -0700 Subject: [PATCH 1/2] handle the case where `last_ts_processed` is None got a TypeError here when we were experimenting with loading data for app store review Testing done: - Reran the pipeline; the error went away --- emission/analysis/intake/segmentation/trip_segmentation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emission/analysis/intake/segmentation/trip_segmentation.py b/emission/analysis/intake/segmentation/trip_segmentation.py index 562b31106..5c11aea05 100644 --- a/emission/analysis/intake/segmentation/trip_segmentation.py +++ b/emission/analysis/intake/segmentation/trip_segmentation.py @@ -149,6 +149,8 @@ def get_last_ts_processed(filter_methods): if last_ts_processed is None or method.last_ts_processed > last_ts_processed: last_ts_processed = method.last_ts_processed logging.debug("Set last_ts_processed = %s from method %s" % (last_ts_processed, method)) + except TypeError as e: + logging.debug("Processing method %s got error %s, skipping" % (method, e)) except AttributeError as e: logging.debug("Processing method %s got error %s, skipping" % (method, e)) logging.info("Returning last_ts_processed = %s" % last_ts_processed) From 46001af6e593f502fdbe56ee22216dcd62a779d3 Mon Sep 17 00:00:00 2001 From: Shankari Date: Mon, 14 Sep 2020 20:43:36 -0700 Subject: [PATCH 2/2] Unify the options for push notifications 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 --- bin/push/push_to_users.py | 6 +++++- bin/push/send_survey.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/push/push_to_users.py b/bin/push/push_to_users.py index d3a27c44b..ae53084f0 100644 --- a/bin/push/push_to_users.py +++ b/bin/push/push_to_users.py @@ -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__': @@ -25,6 +26,7 @@ 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) @@ -32,7 +34,9 @@ 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] diff --git a/bin/push/send_survey.py b/bin/push/send_survey.py index d4db41777..b284dc180 100644 --- a/bin/push/send_survey.py +++ b/bin/push/send_survey.py @@ -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 @@ -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, @@ -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)