From e7cb92421838652e0c52856420c6a5cd60933df1 Mon Sep 17 00:00:00 2001 From: Pawel Szymanski Date: Tue, 7 May 2024 17:27:41 +0100 Subject: [PATCH] Add migration fixes. --- datahub/export_win/legacy_migration.py | 11 +++++++---- .../export_win/test/test_legacy_migration.py | 18 +++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/datahub/export_win/legacy_migration.py b/datahub/export_win/legacy_migration.py index bfd69fe44..7d0d5e325 100644 --- a/datahub/export_win/legacy_migration.py +++ b/datahub/export_win/legacy_migration.py @@ -444,7 +444,10 @@ def resolve_lead_officer(data, context=None): def resolve_line_manager(data, context=None): try: - first_name, last_name = data.get('line_manager_name').split(' ') + parts = data.get('line_manager_name').split() + # In case name is written as "Joe M. Doe" + first_name = parts[0] + last_name = parts[-1] adviser = Advisor.objects.get( first_name__iexact=first_name.strip(), last_name__iexact=last_name.strip(), @@ -486,16 +489,16 @@ def resolve_company_contact(data, context=None): def migrate_all_legacy_wins(): wins = 0 - for page in get_legacy_export_wins_dataset('/data-hub-wins'): + for page in get_legacy_export_wins_dataset('/datasets/data-hub-wins'): for legacy_win in page: migrate_legacy_win(legacy_win) wins += 1 - for page in get_legacy_export_wins_dataset('/data-hub-breakdowns'): + for page in get_legacy_export_wins_dataset('/datasets/data-hub-breakdowns'): for legacy_breakdown in page: migrate_legacy_win_breakdown(legacy_breakdown) - for page in get_legacy_export_wins_dataset('/data-hub-advisers'): + for page in get_legacy_export_wins_dataset('/datasets/data-hub-advisers'): for legacy_adviser in page: migrate_legacy_win_adviser(legacy_adviser) diff --git a/datahub/export_win/test/test_legacy_migration.py b/datahub/export_win/test/test_legacy_migration.py index 9228c7977..cfcdc7691 100644 --- a/datahub/export_win/test/test_legacy_migration.py +++ b/datahub/export_win/test/test_legacy_migration.py @@ -30,19 +30,19 @@ mock_legacy_wins_page_urls = { 'wins': [ - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-wins', - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-wins?cursor=1&source=L', - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-wins?cursor=2&source=E', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-wins', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-wins?cursor=1&source=L', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-wins?cursor=2&source=E', ], 'breakdowns': [ - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-breakdowns', - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-breakdowns?cursor=1&source=L', - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-breakdowns?cursor=2&source=E', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-breakdowns', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-breakdowns?cursor=1&source=L', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-breakdowns?cursor=2&source=E', ], 'advisers': [ - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-advisers', - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-advisers?cursor=1&source=L', - f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/data-hub-advisers?cursor=2&source=E', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-advisers', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-advisers?cursor=1&source=L', + f'{settings.EXPORT_WINS_SERVICE_BASE_URL}/datasets/data-hub-advisers?cursor=2&source=E', ], }