Set user as independent if profile contains no info
If user profile contains only closed intervals for affiliation then mark user as independent when the last interval ends Change-Id: I57e452108390e9c062527710d085c2f49a1f79fb
This commit is contained in:
@@ -37,6 +37,10 @@ def _normalize_user(user):
|
|||||||
return x["end_date"] - y["end_date"]
|
return x["end_date"] - y["end_date"]
|
||||||
|
|
||||||
user['companies'].sort(key=utils.cmp_to_key(end_date_comparator))
|
user['companies'].sort(key=utils.cmp_to_key(end_date_comparator))
|
||||||
|
if user['companies']:
|
||||||
|
if user['companies'][-1]['end_date'] != 0:
|
||||||
|
user['companies'].append(dict(company_name='*independent',
|
||||||
|
end_date=0))
|
||||||
user['user_id'] = user_processor.make_user_id(
|
user['user_id'] = user_processor.make_user_id(
|
||||||
launchpad_id=user.get('launchpad_id'),
|
launchpad_id=user.get('launchpad_id'),
|
||||||
emails=user.get('emails'),
|
emails=user.get('emails'),
|
||||||
|
@@ -25,6 +25,15 @@ DEFAULT_DATA = {
|
|||||||
{'company_name': 'NEC', 'end_date': None},
|
{'company_name': 'NEC', 'end_date': None},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'launchpad_id': 'smith',
|
||||||
|
'user_name': 'Smith',
|
||||||
|
'emails': ['smith@gmail.com', 'smith@nec.com'],
|
||||||
|
'companies': [
|
||||||
|
{'company_name': 'IBM', 'end_date': '2013-May-01'},
|
||||||
|
{'company_name': 'NEC', 'end_date': '2014-Jun-01'}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'launchpad_id': 'ivan_ivanov',
|
'launchpad_id': 'ivan_ivanov',
|
||||||
'user_name': 'Ivan Ivanov',
|
'user_name': 'Ivan Ivanov',
|
||||||
|
@@ -52,6 +52,11 @@ class TestDefaultDataProcessor(testtools.TestCase):
|
|||||||
data['users'][0]['user_id'],
|
data['users'][0]['user_id'],
|
||||||
message='User id should be set')
|
message='User id should be set')
|
||||||
|
|
||||||
|
# verify that *independent company is added automatically
|
||||||
|
self.assertEqual(3, len(data['users'][1]['companies']))
|
||||||
|
self.assertEqual(0, data['users'][1]['companies'][-1]['end_date'],
|
||||||
|
message='The last company end date should be 0')
|
||||||
|
|
||||||
def test_update_project_list(self):
|
def test_update_project_list(self):
|
||||||
with mock.patch('stackalytics.processor.default_data_processor.'
|
with mock.patch('stackalytics.processor.default_data_processor.'
|
||||||
'_retrieve_project_list_from_gerrit') as retriever:
|
'_retrieve_project_list_from_gerrit') as retriever:
|
||||||
|
Reference in New Issue
Block a user