Alternative Name | 21 |Participants | 22 |Non-finished | 23 |Completed | 24 |Conversion Rate | 25 |Confidence | 26 |Finish | 27 |
---|---|---|---|---|---|---|
Totals | 32 |{{ experiment.total_participants }} | 33 |{{ experiment.total_participants - experiment.total_completed }} | 34 |{{ experiment.total_completed }} | 35 |N/A | 36 |N/A | 37 |N/A | 38 |
44 | {{ alternative.name }} 45 | {% if alternative.is_control %} 46 | control 47 | {% endif %} 48 | | 49 |{{ alternative.participant_count }} | 50 |{{ alternative.participant_count - alternative.completed_count }} | 51 |{{ alternative.completed_count }} | 52 |53 | {{ alternative.conversion_rate|percentage }} 54 | {% if experiment.control.conversion_rate > 0 and not alternative.is_control %} 55 | {% if alternative.conversion_rate > experiment.control.conversion_rate %} 56 | 57 | +{{ ((alternative.conversion_rate / experiment.control.conversion_rate) - 1)|percentage }} 58 | 59 | {% elif alternative.conversion_rate < experiment.control.conversion_rate %} 60 | 61 | {{ ((alternative.conversion_rate / experiment.control.conversion_rate) - 1)|percentage }} 62 | 63 | {% endif %} 64 | {% endif %} 65 | | 66 |67 | 68 | {{ alternative.confidence_level }} 69 | 70 | | 71 |72 | {% if experiment.winner %} 73 | {% if experiment.winner.name == alternative.name %} 74 | Winner 75 | {% else %} 76 | Loser 77 | {% endif %} 78 | {% else %} 79 | 83 | {% endif %} 84 | | 85 |
No experiments have been started yet. You need to define them in your code and introduce them to your users.
52 |Check out the documentation for more help getting started.
53 | {% endif %} 54 | {% endblock %} 55 | -------------------------------------------------------------------------------- /flask_split/utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | flask_split.utils 4 | ~~~~~~~~~~~~~~~~~ 5 | 6 | Generic utility functions. 7 | 8 | :copyright: (c) 2012-2015 by Janne Vanhala. 9 | :license: MIT, see LICENSE for more details. 10 | """ 11 | 12 | try: 13 | import urllib.parse as urlparse 14 | except ImportError: 15 | import urlparse 16 | 17 | from flask import current_app 18 | import redis 19 | 20 | 21 | urlparse.uses_netloc.append('redis') 22 | 23 | 24 | def _get_redis_connection(): 25 | """ 26 | Return a Redis connection based on the Flask application's configuration. 27 | 28 | The connection parameters are retrieved from `REDIS_URL` configuration 29 | variable. 30 | 31 | :return: an instance of :class:`redis.Connection` 32 | """ 33 | url = current_app.config.get('REDIS_URL', 'redis://localhost:6379') 34 | return redis.from_url(url, decode_responses=True) 35 | -------------------------------------------------------------------------------- /flask_split/views.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | flask_split.views 4 | ~~~~~~~~~~~~~~~~~ 5 | 6 | This module provides the views for Flask-Split's web interface. 7 | 8 | :copyright: (c) 2012-2015 by Janne Vanhala. 9 | :license: MIT, see LICENSE for more details. 10 | """ 11 | 12 | import os 13 | 14 | from flask import Blueprint, redirect, render_template, request, url_for 15 | 16 | from .models import Alternative, Experiment 17 | from .utils import _get_redis_connection 18 | 19 | 20 | root = os.path.abspath(os.path.dirname(__file__)) 21 | split = Blueprint('split', 'flask_split', 22 | template_folder=os.path.join(root, 'templates'), 23 | static_folder=os.path.join(root, 'static'), 24 | url_prefix='/split' 25 | ) 26 | 27 | 28 | @split.context_processor 29 | def inject_version(): 30 | from . import __version__ 31 | return dict(version=__version__) 32 | 33 | 34 | @split.route('/') 35 | def index(): 36 | """Render a dashboard that lists all active experiments.""" 37 | redis = _get_redis_connection() 38 | return render_template('split/index.html', 39 | experiments=Experiment.all(redis) 40 | ) 41 | 42 | 43 | @split.route('/