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

Negative average time to convert in funnel performance report. #453

Merged
merged 6 commits into from
Jan 9, 2025

Conversation

hemant10yadav
Copy link
Contributor

@hemant10yadav hemant10yadav commented Dec 12, 2024

Copy link
Contributor

@pxwxnvermx pxwxnvermx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙌🏽

Copy link
Collaborator

@calellowitz calellowitz left a 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.

@@ -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",
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed - 8b40e2d

Avg(
ExpressionWrapper(
Greatest(
Subquery(earliest_visits) - F("opportunityaccess__invited_date"),
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor Author

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

@hemant10yadav hemant10yadav merged commit 6b92e4f into main Jan 9, 2025
5 checks passed
@hemant10yadav hemant10yadav deleted the hy/reports-issue branch January 9, 2025 03:00
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

Successfully merging this pull request may close these issues.

4 participants