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

Show conversions rounded to the nearest tenth decimal place #63

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions wagtail_ab_testing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.core.serializers.json import DjangoJSONEncoder
from django.shortcuts import get_object_or_404, redirect, render
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils import formats, timezone
from django.utils.functional import cached_property
from django.utils.translation import gettext as _, gettext_lazy
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -375,6 +375,14 @@ def get_progress_and_results_common_context(request, page, ab_test):
}
)

# Format stats for display
control_conversions_percent = formats.localize(
round(control_conversions / control_participants * 100, 1)
) if control_participants else 0
variant_conversions_percent = formats.localize(
round(variant_conversions / variant_participants * 100, 1)
) if variant_conversions else 0

return {
"page": page,
"ab_test": ab_test,
Expand All @@ -384,18 +392,10 @@ def get_progress_and_results_common_context(request, page, ab_test):
),
"control_conversions": control_conversions,
"control_participants": control_participants,
"control_conversions_percent": int(
control_conversions / control_participants * 100
)
if control_participants
else 0,
"control_conversions_percent": control_conversions_percent,
"variant_conversions": variant_conversions,
"variant_participants": variant_participants,
"variant_conversions_percent": int(
variant_conversions / variant_participants * 100
)
if variant_participants
else 0,
"variant_conversions_percent": variant_conversions_percent,
"control_is_winner": ab_test.winning_version == AbTest.VERSION_CONTROL,
"variant_is_winner": ab_test.winning_version == AbTest.VERSION_VARIANT,
"unclear_winner": ab_test.status
Expand Down
Loading