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.
This commit is contained in:
Steve Howell 2018-11-17 15:50:55 +00:00 committed by Tim Abbott
parent bd1e96cf63
commit ad35e371fe
1 changed files with 10 additions and 0 deletions

View File

@ -88,6 +88,7 @@ def read_user_data(data_dir: str) -> List[ZerverFieldsT]:
return ujson.load(fp) return ujson.load(fp)
def convert_user_data(user_handler: UserHandler, def convert_user_data(user_handler: UserHandler,
slim_mode: bool,
user_id_mapper: IdMapper, user_id_mapper: IdMapper,
raw_data: List[ZerverFieldsT], raw_data: List[ZerverFieldsT],
realm_id: int) -> None: realm_id: int) -> None:
@ -96,6 +97,12 @@ def convert_user_data(user_handler: UserHandler,
for d in raw_data 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: def process(in_dict: ZerverFieldsT) -> ZerverFieldsT:
delivery_email = in_dict['email'] delivery_email = in_dict['email']
email = in_dict['email'] email = in_dict['email']
@ -738,10 +745,13 @@ def do_convert_data(input_tar_file: str,
realm_id = 0 realm_id = 0
realm = make_realm(realm_id=realm_id) realm = make_realm(realm_id=realm_id)
slim_mode = True
# users.json -> UserProfile # users.json -> UserProfile
raw_user_data = read_user_data(data_dir=input_data_dir) raw_user_data = read_user_data(data_dir=input_data_dir)
convert_user_data( convert_user_data(
user_handler=user_handler, user_handler=user_handler,
slim_mode=slim_mode,
user_id_mapper=user_id_mapper, user_id_mapper=user_id_mapper,
raw_data=raw_user_data, raw_data=raw_user_data,
realm_id=realm_id, realm_id=realm_id,