-
Notifications
You must be signed in to change notification settings - Fork 1
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
Negative average time to convert in funnel performance report. #453
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 🙌🏽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple questions, but mostly curious what the cause of the negative values was and if we can avoid that rather than just floor it at a different arbitrary value.
commcare_connect/program/helpers.py
Outdated
@@ -50,7 +52,7 @@ def get_annotated_managed_opportunity(program: Program): | |||
.annotate( | |||
workers_invited=Count("opportunityaccess", distinct=True), | |||
workers_passing_assessment=Count( | |||
"opportunityaccess__assessment", | |||
"opportunityaccess__assessment__opportunity_access", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like it traverses a foreign key in two directions, can we not just skip the join entirely and count opportunity accesses that meet the filter below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed - 8b40e2d
commcare_connect/program/helpers.py
Outdated
Avg( | ||
ExpressionWrapper( | ||
Greatest( | ||
Subquery(earliest_visits) - F("opportunityaccess__invited_date"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this end up negative? I see that we floor it at zero, but why is that necessary? Zero seems equally wrong if we trigger that condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue occurred because we recently added the invited_date
field with auto_now_add
=True. As a result, invited_date was set to now(
) during the migration for earlier records.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that means the average will still be wrong right? since it includes a bunch of incorrect zeros mixed in with real data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and added test also -944785e
CCCT-570
CCCT-585