Skip to content

Commit 73e2190

Browse files
authored
Merge pull request #142 from IDEMSInternational/update-models-for-surveys
Update models for surveys
2 parents eb877bf + e9bd54f commit 73e2190

File tree

3 files changed

+59
-23
lines changed

3 files changed

+59
-23
lines changed

Diff for: src/parenttext_pipeline/configs.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,42 @@ class UpdateExpirationStepConfig(StepConfig):
5151

5252
@dataclass(kw_only=True)
5353
class QRTreatmentStepConfig(StepConfig):
54+
5455
# str: how to process quick replies
5556
# move: Remove quick replies and add equivalents to them to the message text,
5657
# and give numerical prompts to allow basic phone users to use the app.
5758
# move_and_mod: As above but has additional functionality allowing you
5859
# to replace phrases
5960
# reformat: Reformat quick replies so that long ones are added to the message text,
6061
# as above.
62+
# reformat_whatsapp: Reformat quick replies to meet the length and message restrictions of whatsapp
63+
# reformat_palestine: Reformat quick replies to the standard as needed by Palestine
6164
# reformat_china: Reformat quick replies to the standard as requested by China
6265
# wechat: All quick replies moved to links in message text as can be used in WeChat
6366
qr_treatment: str
64-
# ???
65-
qr_limit: int = 10
67+
6668
# When qr_treatment is 'reformat',
6769
# set limits on the number of quick replies that are processed.
6870
# If the number of quick replies is below or equal to count_threshold
6971
# then the quick replies are left in place.
7072
count_threshold: str = None
73+
7174
# When qr_treatment is 'reformat', set limits on the number of quick replies
7275
# that are processed. If the character-length of the longest quick reply is
7376
# below or equal to length_threshold then the quick replies are left in place.
7477
length_threshold: str = None
78+
79+
# When qr_treatment is 'reformat', assuming that we are moving quick replies to
80+
# message text. Normally we add numerical quick replies back in, but if the number of
81+
# quick replies is above the qr_limit then numerical quick replies are not added.
82+
# Should be used where platforms have limits on the number of quick replies they can send
83+
# Default is set at 10 as that is the limit on whatsapp
84+
qr_limit: int = 10
85+
7586
# If qr_treatment is 'move', add some basic numerical quick replies back in.
7687
# Valid values are 'yes' or 'no'.
7788
add_selectors: str = None
89+
7890
# Path to file with the default phrase (including translations) we want to add
7991
# if quick replies are being moved to message text.
8092
replace_phrases: str = ""

Diff for: src/parenttext_pipeline/models/parenttext_models.py

+33-21
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ class VariableModel(DataRowModel):
99

1010

1111
class AttachmentModel(ParserModel):
12-
file_type: str = ""
13-
url: str = ""
14-
15-
12+
file_type: str = ''
13+
url: str = ''
14+
15+
class MetadataModel(ParserModel):
16+
description: str = ''
17+
###################################################################
1618
class IntroductionBlockModel(ParserModel):
1719
msg_list: List[str] = []
1820

@@ -192,6 +194,16 @@ class RelevantModel(ParserModel):
192194
condition_type: str = ""
193195

194196

197+
198+
class IntroModel(DataRowModel):
199+
filter_list: List[str] = ""
200+
relevant: List[RelevantModel] = []
201+
msg: List[str] = []
202+
next_button_option: str = ''
203+
attachment: AttachmentModel = AttachmentModel()
204+
metadata: MetadataModel = MetadataModel()
205+
206+
195207
class OnboardingStepsModel(DataRowModel):
196208
flow: str = ""
197209
survey_id: str = ""
@@ -221,30 +233,32 @@ class OnboardingQuestionWithOptionsModel(DataRowModel):
221233
excluded_values: List[str] = []
222234
confirm_question: str = ""
223235
go_back_opt: str = ""
236+
proceed_opt: str = ""
224237
stop_opt: str = ""
225238
stop_message: str = ""
226239
update_flow: str = ""
227240
relevant: List[RelevantModel] = []
228241

229242

230243
class OnboardingQuestionInputTestModel(ParserModel):
231-
expression: str = ""
232-
value: str = ""
233-
condition_type: str = ""
234-
244+
expression: str = ''
245+
value: str = ''
246+
condition_type: str = ''
247+
error_message: str = ''
235248

236249
class OnboardingQuestionInputModel(DataRowModel):
237-
question: str = ""
238-
variable: str = ""
239-
skip_option: str = ""
240-
skip_value: str = ""
241-
test: OnboardingQuestionInputTestModel = OnboardingQuestionInputTestModel()
242-
error_message: str = ""
243-
capitalise: str = ""
244-
attached_single_doc: str = ""
245-
relevant: List[RelevantModel] = []
246-
update_flow: str = ""
247-
250+
filter_list: List[str] = ""
251+
question: str = ''
252+
variable: str = ''
253+
skip_option: str = ''
254+
skip_value: str = ''
255+
test: OnboardingQuestionInputTestModel = OnboardingQuestionInputTestModel()
256+
tests: List[OnboardingQuestionInputTestModel] = []
257+
error_message: str = ''
258+
capitalise: str = ''
259+
attached_single_doc: str = ''
260+
relevant: List[RelevantModel] = []
261+
update_flow: str = ''
248262

249263
class OnboardingRangeModel(ParserModel):
250264
limit: str = ""
@@ -496,8 +510,6 @@ class CongratsDataModel(DataRowModel):
496510
extra_msg: str = ""
497511

498512

499-
class MetadataModel(ParserModel):
500-
description: str = ""
501513

502514

503515
class SingleMessageModel(DataRowModel):

Diff for: src/parenttext_pipeline/steps.py

+12
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ def apply_qr_treatment(config, step_config, step_number, step_input_file):
141141
special_words_file,
142142
)
143143
print("Step 8 complete, reformatted quick replies")
144+
elif step_config.qr_treatment == "reformat_palestine":
145+
run_node(
146+
"idems_translation_chatbot/index.js",
147+
"reformat_quick_replies_palestine",
148+
step_input_file,
149+
select_phrases_file,
150+
step_output_basename,
151+
config.temppath,
152+
str(step_config.qr_limit),
153+
special_words_file,
154+
)
155+
print("Step 8 complete, reformatted quick replies palestine")
144156
elif step_config.qr_treatment == "reformat_china":
145157
run_node(
146158
"idems_translation_chatbot/index.js",

0 commit comments

Comments
 (0)