From 248d46b113007dbb6a8ad1f94d9276685fff6af2 Mon Sep 17 00:00:00 2001 From: Chris Coffey Date: Fri, 9 Jul 2021 14:07:46 -0400 Subject: [PATCH] Instead of loading groups as questions, extract their sub-fields and load these a questions Typo Typo --- tap_typeform/streams.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tap_typeform/streams.py b/tap_typeform/streams.py index eb9c6f0..6b275e9 100644 --- a/tap_typeform/streams.py +++ b/tap_typeform/streams.py @@ -105,12 +105,19 @@ def sync_form_definition(atx, form_id): # we only care about a few fields in the form definition # just those that give an analyst a reference to the submissions for row in data: - definition_data_rows.append({ - "form_id": form_id, - "question_id": row['id'], - "title": row['title'], - "ref": row['ref'] - }) + # Groups aren't questions themselves, but they contain one or + # more questions. So extract them and add them to the back of the + # fields queue + if row['type'] == 'group': + sub_questions = row['properties']['fields'] + data += sub_questions + else: + definition_data_rows.append({ + "form_id": form_id, + "question_id": row['id'], + "title": row['title'], + "ref": row['ref'] + }) write_records(atx, 'questions', definition_data_rows)