FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 7c19b032 authored by Dr T. Mona's avatar Dr T. Mona
Browse files

feat: handle one letter format of incident category alongside short name.

parent fb82d0ff
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,19 @@ from ProcessorUtils import (
logger = logging.getLogger('Processor.Surveys.kobotoolbox')
add_filters_to_sublogger(logger)
# Cases to convert incident categories to expected short name category or value
cases_incident = {
'':'none',
'N':'none',
'L':'low',
'M':'medium',
'H':'high',
'none':'none',
'low':'low',
'medium':'medium',
'high':'high'
}
def get_from_kobotoolbox(url,form_id,form_token,**kwargs):
'''Make the HTTP request, then checking the status code.'''
......@@ -95,7 +108,7 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s
'formhub/uuid' : 'None',
'imei' : 'imei',
'leaf_rust/leafrust_host_plant_reaction' : 'leaf_rust-leafrust_host_plant_reaction',
'leaf_rust/leafrust_incidence' : 'leaf_rust-leafrust_incidence',
'leaf_rust/leafrust_incidence' : ('parse_cases',(('name_out','leaf_rust-leafrust_incidence'),('cases', cases_incident))),
'leaf_rust/leafrust_severity' : 'leaf_rust-leafrust_severity',
'live_leafrust_samples' : 'SET-OF-live_leafrust_samples',
'live_leafrust_samples_count' : 'live_leafrust_samples_count',
......@@ -116,7 +129,7 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s
'start' : ('parse_date',(('name_out','start'),('fmt_in','%Y-%m-%dT%H:%M:%S.%f%z'))),
'stem_rust/Stemrust_severity' : 'stem_rust-Stemrust_severity',
'stem_rust/stemrust_host_plant_reaction' : 'stem_rust-stemrust_host_plant_reaction',
'stem_rust/stemrust_incidence' : 'stem_rust-stemrust_incidence',
'stem_rust/stemrust_incidence' : ('parse_cases',(('name_out','stem_rust-stemrust_incidence'),('cases', cases_incident))),
'survey_infromation/location' : ('parse_location_kobotoolbox',()),
'survey_infromation/location_name' : 'survey_infromation-location_name',
'survey_infromation/survey_date' : ('parse_date',(('name_out','survey_infromation-survey_date'),('fmt_in','%Y-%m-%d'))),
......@@ -126,7 +139,7 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s
'today' : ('parse_date',(('name_out','today'),('fmt_in','%Y-%m-%d'))),
'username' : 'username',
'yellow_rust/yellowrust_host_plant_reaction' : 'yellow_rust-yellowrust_host_plant_reaction',
'yellow_rust/yellowrust_incidence' : 'yellow_rust-yellowrust_incidence',
'yellow_rust/yellowrust_incidence' : ('parse_cases',(('name_out','leaf_rust-leafrust_incidence'),('cases', cases_incident))),
'yellow_rust/yellowrust_severity' : 'yellow_rust-yellowrust_severity',
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment