Properly handle user profiles without names

If user is mentioned only as co-author in commit and has no
other contribution, nor registered at Launchpad then a profile
is created with empty name. Since the name is required across
the code, use user_id instead of it.

Change-Id: I87bb9cf186d05a6f1299f3150306dcbc01b02fdc
This commit is contained in:
Ilya Shakhat 2018-01-12 16:02:44 +01:00
parent 6e16f32952
commit d8912f9e3d
2 changed files with 5 additions and 1 deletions

View File

@ -453,7 +453,7 @@ def get_users_json(record_ids, **kwargs):
result = []
for user_id in user_ids:
user = vault.get_user_from_runtime_storage(user_id)
r = {'id': user_id, 'text': user['user_name']}
r = {'id': user_id, 'text': user.get('user_name') or user['user_id']}
add_flag = not core_in
if core_in and user.get('core'):

View File

@ -208,6 +208,10 @@ def merge_user_profiles(domains_index, user_profiles):
merged_user['user_id'] = (merged_user.get('launchpad_id') or
merged_user.get('user_id'))
# always preserve `user_name` since its required field
if 'user_name' not in merged_user:
merged_user['user_name'] = merged_user['user_id']
# merge emails
emails = set([])
core_in = set([])