From ad35e371fe1887ffd4f23ce3b0055ddb71ae7ff1 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 17 Nov 2018 15:50:55 +0000 Subject: [PATCH] hipchat: Support slim_mode flag. We now skip deleted users. There is a flag here that's hard coded to True--we may decide later to make this a command line option. --- zerver/data_import/hipchat.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zerver/data_import/hipchat.py b/zerver/data_import/hipchat.py index 4233b0098b..c4cc4f3fd4 100755 --- a/zerver/data_import/hipchat.py +++ b/zerver/data_import/hipchat.py @@ -88,6 +88,7 @@ def read_user_data(data_dir: str) -> List[ZerverFieldsT]: return ujson.load(fp) def convert_user_data(user_handler: UserHandler, + slim_mode: bool, user_id_mapper: IdMapper, raw_data: List[ZerverFieldsT], realm_id: int) -> None: @@ -96,6 +97,12 @@ def convert_user_data(user_handler: UserHandler, for d in raw_data ] + if slim_mode: + flat_data = [ + d for d in flat_data + if not d['is_deleted'] + ] + def process(in_dict: ZerverFieldsT) -> ZerverFieldsT: delivery_email = in_dict['email'] email = in_dict['email'] @@ -738,10 +745,13 @@ def do_convert_data(input_tar_file: str, realm_id = 0 realm = make_realm(realm_id=realm_id) + slim_mode = True + # users.json -> UserProfile raw_user_data = read_user_data(data_dir=input_data_dir) convert_user_data( user_handler=user_handler, + slim_mode=slim_mode, user_id_mapper=user_id_mapper, raw_data=raw_user_data, realm_id=realm_id,