Skip to content

Commit

Permalink
Merge pull request #5403 from uktrade/fix/export-wins-migration
Browse files Browse the repository at this point in the history
Add migration fixes.
  • Loading branch information
elcct authored May 8, 2024
2 parents 027a996 + e7cb924 commit 2908687
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
11 changes: 7 additions & 4 deletions datahub/export_win/legacy_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)

Expand Down
18 changes: 9 additions & 9 deletions datahub/export_win/test/test_legacy_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
}

Expand Down

0 comments on commit 2908687

Please sign in to comment.