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

monitoring: Add a graph of completion rate by section #685

Open
tahini opened this issue Sep 12, 2024 · 1 comment
Open

monitoring: Add a graph of completion rate by section #685

tahini opened this issue Sep 12, 2024 · 1 comment

Comments

@tahini
Copy link
Contributor

tahini commented Sep 12, 2024

Such a graph exists in od_mtl, but we use an adminView to get the completion data. We could get it with a query directly, but it could be a long query for large surveys. The default implementation could be with a direct query to the responses and we can change to adminView when required.

Here's the query to get the section status:

select i.id, s.key as section_name, (s.value::json->>'_startedAt') as started_at, case when (s.value::json->>'_isCompleted')::boolean is not true then false else true end as is_completed
from sv_interviews i
left join json_each_text(responses->'_sections') s on true
where s.key != '_actions'

We can then use a group by and sum/count to get started/completed

@tahini
Copy link
Contributor Author

tahini commented Sep 12, 2024

Here's the complete query to give the completion ratio for a survey (note that for person specific sections, completion is per person, so this query will return 0 for those sections. It does not mean they are not complete:

select section_name, count(id), sum(is_completed) from (
select i.id, s.key as section_name, (s.value::json->>'_startedAt') as started_at, case when (s.value::json->>'_isCompleted')::boolean is not true then 0 else 1 end as is_completed
from sv_interviews i
left join json_each_text(responses->'_sections') s on true
where s.key != '_actions'
) group by section_name
order by count(id) desc

To implement the widget, search for getStartedAndCompletedInterviewsByDay and started-and-completed-interviews-by-day in the code to get inspiration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant