Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLS2-1069 Fix marketing data ingestion bug #5830

Merged
merged 4 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datahub/investment_lead/tasks/ingest_eyb_marketing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class EYBMarketingDataIngestionTask(BaseEYBDataIngestionTask):
"""Long running job to read the marketing file contents and ingest the records."""

def _get_hashed_uuid(self, obj):
return obj.get('hashed_uuid', None)
return None if obj is None else obj.get('hashed_uuid', None)

def _record_has_no_changes(self, record):
hashed_uuid = self._get_hashed_uuid(record['object'])
hashed_uuid = self._get_hashed_uuid(record.get('object'))
if hashed_uuid and EYBLead.objects.filter(marketing_hashed_uuid=hashed_uuid).exists():
return True
return False
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ def test_marketing_data_ingestion_does_not_update_existing(self, test_marketing_
updated = EYBLead.objects.get(marketing_hashed_uuid=hashed_uuid)
assert updated.utm_content == initial_value

@mock_aws
def test_marketing_data_ingestion_does_not_fail_with_empty_records(
self,
test_marketing_file_path,
):
"""Test previously ingested records do not trigger an update to the existing instance."""
hashed_uuid = generate_hashed_uuid()
initial_value = 'initial value'
EYBLeadFactory(marketing_hashed_uuid=hashed_uuid, utm_content=initial_value)
assert EYBLead.objects.count() == 1
records = []
file_contents = file_contents_faker(records)
setup_s3_bucket(BUCKET, [test_marketing_file_path], [file_contents])
ingest_eyb_marketing_data(BUCKET, test_marketing_file_path)
assert EYBLead.objects.count() == 1
updated = EYBLead.objects.get(marketing_hashed_uuid=hashed_uuid)
assert updated.utm_content == initial_value

@mock_aws
def test_incoming_marketing_records_trigger_correct_logging(self, caplog):
"""Test that incoming marketing correct logging messages.
Expand Down