Skip to content

Commit

Permalink
fix: update citation when updating dataset title (#7311)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayib-jose-gloria authored Jul 26, 2024
1 parent 735af7b commit eb03bca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/layers/business/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ def trigger_dataset_artifact_update(
new_dataset_version_id = self.create_empty_dataset_version_for_current_dataset(
collection_version.version_id, current_dataset_version_id
).version_id
# Update citation for new dataset version
doi = next((link.uri for link in collection_version.metadata.links if link.type == "DOI"), None)
metadata_update.citation = self.generate_dataset_citation(
collection_version.collection_id, new_dataset_version_id, doi
)

self.batch_job_provider.start_metadata_update_batch_job(
current_dataset_version_id, new_dataset_version_id, metadata_update
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/backend/layers/business/test_business.py
Original file line number Diff line number Diff line change
Expand Up @@ -3077,7 +3077,10 @@ def test_trigger_dataset_artifact_update(self):
current_dataset_version_id = revision.datasets[0].version_id
self.batch_job_provider.start_metadata_update_batch_job = Mock()
self.business_logic.trigger_dataset_artifact_update(revision, metadata_update, current_dataset_version_id)

self.batch_job_provider.start_metadata_update_batch_job.assert_called_once()
# Confirm citation is updated if new dataset version is generated as part of trigger_dataset_artifact_update
self.assertIsNotNone(metadata_update.citation)

def test_trigger_dataset_artifact_update__with_new_dataset_version_id(self):
metadata_update = DatasetArtifactMetadataUpdate(schema_version="4.0.0")
Expand Down

0 comments on commit eb03bca

Please sign in to comment.