From d8912f9e3da8bb00f01b954f81ad8a1064dfe030 Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Fri, 12 Jan 2018 16:02:44 +0100 Subject: [PATCH] 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 --- stackalytics/dashboard/web.py | 2 +- stackalytics/processor/user_processor.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/stackalytics/dashboard/web.py b/stackalytics/dashboard/web.py index e72308c03..069d31aed 100644 --- a/stackalytics/dashboard/web.py +++ b/stackalytics/dashboard/web.py @@ -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'): diff --git a/stackalytics/processor/user_processor.py b/stackalytics/processor/user_processor.py index cf2562c4c..117e109ed 100644 --- a/stackalytics/processor/user_processor.py +++ b/stackalytics/processor/user_processor.py @@ -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([])