Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create autoreport even when non-numeric value exists in numeric field #185

Closed
jnm opened this issue Dec 5, 2018 · 0 comments · Fixed by #186
Closed

Create autoreport even when non-numeric value exists in numeric field #185

jnm opened this issue Dec 5, 2018 · 0 comments · Fixed by #186
Assignees
Labels

Comments

@jnm
Copy link
Member

jnm commented Dec 5, 2018

Quick summary

Because the autoreport in KPI is displayed alongside

Warning
This is an automated report based on raw data submitted to this project. Please conduct proper data cleaning prior to using the graphs and figures used on this page.

...we should treat invalid responses as if they were blank when calculating statistics.

Explanation

This problem is a manifestation of #151. Consider a form with two versions:

Version 1

type name label
start start
end end
text i_started_life_as_a_text_question i started life as a text question

Version 2

type name label
start start  
end end  
integer i_started_life_as_a_text_question i started life as a text question

If I submit hello while version 1 is deployed and 123 while version 2 is deployed, the autoreport will fail at

def parse_values(self, raw_values):
if self.data_type == "integer":
yield int(raw_values)
else:
yield float(raw_values)

ValueError: invalid literal for int() with base 10: 'hello'
  <snip>
  File "kobo/apps/reports/report_data.py", line 178, in data_by_identifiers
    split_by=split_by)
  File "formpack/reporting/autoreport.py", line 209, in get_stats
    return self._calculate_stats(submissions, fields, self.versions, lang)
  File "formpack/reporting/autoreport.py", line 73, in _calculate_stats
    values = list(field.parse_values(raw_value))
  File "formpack/schema/fields.py", line 515, in parse_values
    yield int(raw_values)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants