From 4d163b25f4a1a1d3a4ac3d1d334946e44dc5b173 Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Wed, 23 Oct 2019 08:44:17 +0100 Subject: [PATCH] #100: Generate datasets per investigation --- util/icat_db_generator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/icat_db_generator.py b/util/icat_db_generator.py index b39479a5..444e4b97 100644 --- a/util/icat_db_generator.py +++ b/util/icat_db_generator.py @@ -522,7 +522,7 @@ def generate_study_investigation(i): class DatasetGenerator(Generator): tier = 4 - amount = InvestigationGenerator.amount # One Dataset per investigation + amount = InvestigationGenerator.amount * 2 # Two Datasets per investigation def generate(self): self.pool_map(DatasetGenerator.generate_dataset) @@ -533,8 +533,10 @@ def generate_dataset(i): apply_common_attributes(dataset, i) dataset.COMPLETE = randrange(2) dataset.LOCATION = faker.file_path() - dataset.INVESTIGATION_ID = i - dataset.SAMPLE_ID = i + investigation_id = i % InvestigationGenerator.amount + dataset.INVESTIGATION_ID = investigation_id if investigation_id != 0 else InvestigationGenerator.amount - 1 + sample_id = i % SampleGenerator.amount + dataset.SAMPLE_ID = sample_id if sample_id != 0 else SampleGenerator.amount - 1 dataset.TYPE_ID = randrange(1, DatasetTypeGenerator.amount) post_entity(dataset)