Skip to content

Commit

Permalink
Update dummy data creation to pass in a flag to generate themes or not.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmenezes0 committed Apr 4, 2024
1 parent 7d4f251 commit 80fd8f1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions consultation_analyser/consultations/dummy_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class DummyConsultation:
def __init__(self, responses=10, **options):
def __init__(self, responses=10, include_themes=True, **options):
if not HostingEnvironment.is_local():
raise RuntimeError("Dummy data generation should only be run in development")

Expand All @@ -24,10 +24,11 @@ def __init__(self, responses=10, **options):
response = ConsultationResponseFactory(consultation=consultation)
_answers = [AnswerFactory(question=q, consultation_response=response) for q in questions]

# Set themes per question, multiple answers with the same theme
for q in questions:
themes = [ThemeFactory() for _ in range(2, 6)]
for a in _answers:
random_theme = random.choice(themes)
a.theme = random_theme
a.save()
if include_themes:
# Set themes per question, multiple answers with the same theme
for q in questions:
themes = [ThemeFactory() for _ in range(2, 6)]
for a in _answers:
random_theme = random.choice(themes)
a.theme = random_theme
a.save()

0 comments on commit 80fd8f1

Please sign in to comment.