<commit_before>{% extends "_base.html" %}

{% block scripts %}
{{super()}}
<script src="{{url_for('.static', filename='js/bootstrap-datetimepicker.min.js')}}"></script>

<script type="text/javascript">
    function reload_with_date(start_date, end_date) {
        window.location.href = flask_util.url_for('dashboard', {start_date: start_date.startOf('day').format(), end_date: end_date.endOf('day').format()});
    }

    $( document ).ready(function() {
        <!-- Pre-select the date time period dropdown by the selected date range -->
        var start_date = moment("{{start_date}}");
        var end_date = moment("{{end_date}}");
        <!-- Determine configured time period -->
        var period = "custom";
        if(start_date.isSame(moment(end_date).subtract(1, 'weeks').startOf('day'))) {
          period = "1 week";
        }
        else if(start_date.isSame(moment(end_date).subtract(1, 'months').startOf('day'))) {
          period = "1 month";
        }
        else if(start_date.isSame(moment(end_date).subtract(1, 'years').startOf('day'))) {
          period = "1 year";
        }
        else if(start_date.isSame(moment().year(1970).month(0).date(1).startOf('day'))) {
          period = "all moves";
        }
        $(".dropdown").find('.btn').find('.selection').text(period);
    });

    $(function () {
        <!-- Date time picker configuration -->
        $('#dtp_start').datetimepicker({
            defaultDate: '{{start_date}}',
            maxDate: '{{end_date}}',
            format: 'LL',          <!-- http://momentjs.com/docs/#/displaying/format/ -->
            calendarWeeks: true,
            showTodayButton: true
        });
        $('#dtp_end').datetimepicker({
            defaultDate: '{{end_date}}',
            minDate: '{{start_date}}',
            format: 'LL',          <!-- http://momentjs.com/docs/#/displaying/format/ -->
            calendarWeeks: true,
            showTodayButton: true
        });

        <!-- Linked date time pickers: http://eonasdan.github.io/bootstrap-datetimepicker/#linked-pickers -->
        $("#dtp_start").on("dp.change",function (e) {
            reload_with_date($('#dtp_start').data("DateTimePicker").date(), $('#dtp_end').data("DateTimePicker").date());
        });
        $("#dtp_end").on("dp.change",function (e) {
            reload_with_date($('#dtp_start').data("DateTimePicker").date(), $('#dtp_end').data("DateTimePicker").date());
        });

        $(".dropdown-menu li a").click(function(){
          $(this).parents(".dropdown").find('.btn').find('.selection').text($(this).text());
          var start_date = null;
          switch($(this).text()) {
              case "1 week":
                  start_date = moment().subtract(1, 'weeks');
                  break;
              case "1 month":
                  start_date = moment().subtract(1, 'months');
                  break;
              case "1 year":
                  start_date = moment().subtract(1, 'years');
                  break;
              case "all moves":
                  start_date = moment().year(1970).month(0).date(1);
                  break;
              default:
                  start_date = moment().subtract(1, 'months');
                  break;
          }
          reload_with_date(start_date, moment());
          ;
        });
    });
</script>

{% endblock %}

{% block styles %}
{{super()}}
<link rel="stylesheet" href="{{url_for('.static', filename='css/bootstrap-datetimepicker.css')}}">
{% endblock %}

{% set active_page = 'dashboard' -%}

{% block content %}
{{super()}}
<div class="container" role="main">
    <h3>Dashboard</h3>
    <div class="container">
        <div class='col-md-3'>
              <div>from:</div>
            <div class="form-group">
                <div class='input-group date' id='dtp_start'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
        <div class='col-md-3'>
            <div>to:</div>
            <div class="form-group">
                <div class='input-group date' id='dtp_end'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
        <div class='col-md-1'>
            <div>&nbsp;</div>
            <!-- http://stackoverflow.com/questions/13437446/how-to-display-selected-item-in-bootstrap-button-dropdown-title -->
            <div class="dropdown">
              <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
                Period: <strong><span class="selection">1 week</span></strong>
                <span class="caret"></span>
              </button>
              <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">1 week</a></li>
                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">1 month</a></li>
                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">1 year</a></li>
                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">all moves</a></li>
              </ul>
            </div>
        </div>
    </div>

    <h3>Totals</h3>
    <table class="table table-striped table-auto-width">
      <tr><th>#Moves</th><td>{{nr_of_moves}}</td></tr>
      {% if nr_of_moves > 0 %}
      <tr><th>Total Distance</th><td>{{macros.format_distance(total_distance)}}</td></tr>
      <tr><th>Total Time</th><td>{{macros.format_duration(total_duration)}}</td></tr>
      <tr><th>Total Ascent</th><td>{{macros.format_hm(total_ascent)}}</td></tr>
      <tr><th>Total Descent</th><td>{{macros.format_hm(total_descent)}}</td></tr>
      {% endif %}
    </table>

    {% if nr_of_moves > 0 %}
    <h3>Activity Totals</h3>
    <div class="col-md-3">
        <table class="table table-hover">
            <thead>
                <tr><th>by Distance</th><th></th></tr>
            </thead>
            <tbody>
                {% for activity in descent_sums.keys() %}
                    <tr><td>{{activity}}</td><td>{{macros.format_hm(descent_sums[activity])}}</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="col-md-3">
        <table class="table table-hover">
            <thead>
                <tr><th>by Duration</th><th></th></tr>
            </thead>
            <tbody>
                {% for activity in duration_sums.keys() %}
                    <tr><td>{{activity}}</td><td>{{macros.format_duration(duration_sums[activity])}}</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="col-md-3">
        <table class="table table-hover">
            <thead>
                <tr><th>by Ascent</th><th></th></tr>
            </thead>
            <tbody>
                {% for activity in ascent_sums.keys() %}
                    <tr><td>{{activity}}</td><td>{{macros.format_duration(ascent_sums[activity])}}</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="col-md-3">
        <table class="table table-hover">
            <thead>
                <tr><th>by Descent</th><th></th></tr>
            </thead>
            <tbody>
                {% for activity in descent_sums.keys() %}
                    <tr><td>{{activity}}</td><td>{{macros.format_duration(descent_sums[activity])}}</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% endif %}
</div>
{% endblock %}<commit_msg>Fix incorrect visualization of distance (descent shown instead)<commit_after>{% extends "_base.html" %}

{% block scripts %}
{{super()}}
<script src="{{url_for('.static', filename='js/bootstrap-datetimepicker.min.js')}}"></script>

<script type="text/javascript">
    function reload_with_date(start_date, end_date) {
        window.location.href = flask_util.url_for('dashboard', {start_date: start_date.startOf('day').format(), end_date: end_date.endOf('day').format()});
    }

    $( document ).ready(function() {
        <!-- Pre-select the date time period dropdown by the selected date range -->
        var start_date = moment("{{start_date}}");
        var end_date = moment("{{end_date}}");
        <!-- Determine configured time period -->
        var period = "custom";
        if(start_date.isSame(moment(end_date).subtract(1, 'weeks').startOf('day'))) {
          period = "1 week";
        }
        else if(start_date.isSame(moment(end_date).subtract(1, 'months').startOf('day'))) {
          period = "1 month";
        }
        else if(start_date.isSame(moment(end_date).subtract(1, 'years').startOf('day'))) {
          period = "1 year";
        }
        else if(start_date.isSame(moment().year(1970).month(0).date(1).startOf('day'))) {
          period = "all moves";
        }
        $(".dropdown").find('.btn').find('.selection').text(period);
    });

    $(function () {
        <!-- Date time picker configuration -->
        $('#dtp_start').datetimepicker({
            defaultDate: '{{start_date}}',
            maxDate: '{{end_date}}',
            format: 'LL',          <!-- http://momentjs.com/docs/#/displaying/format/ -->
            calendarWeeks: true,
            showTodayButton: true
        });
        $('#dtp_end').datetimepicker({
            defaultDate: '{{end_date}}',
            minDate: '{{start_date}}',
            format: 'LL',          <!-- http://momentjs.com/docs/#/displaying/format/ -->
            calendarWeeks: true,
            showTodayButton: true
        });

        <!-- Linked date time pickers: http://eonasdan.github.io/bootstrap-datetimepicker/#linked-pickers -->
        $("#dtp_start").on("dp.change",function (e) {
            reload_with_date($('#dtp_start').data("DateTimePicker").date(), $('#dtp_end').data("DateTimePicker").date());
        });
        $("#dtp_end").on("dp.change",function (e) {
            reload_with_date($('#dtp_start').data("DateTimePicker").date(), $('#dtp_end').data("DateTimePicker").date());
        });

        $(".dropdown-menu li a").click(function(){
          $(this).parents(".dropdown").find('.btn').find('.selection').text($(this).text());
          var start_date = null;
          switch($(this).text()) {
              case "1 week":
                  start_date = moment().subtract(1, 'weeks');
                  break;
              case "1 month":
                  start_date = moment().subtract(1, 'months');
                  break;
              case "1 year":
                  start_date = moment().subtract(1, 'years');
                  break;
              case "all moves":
                  start_date = moment().year(1970).month(0).date(1);
                  break;
              default:
                  start_date = moment().subtract(1, 'months');
                  break;
          }
          reload_with_date(start_date, moment());
          ;
        });
    });
</script>

{% endblock %}

{% block styles %}
{{super()}}
<link rel="stylesheet" href="{{url_for('.static', filename='css/bootstrap-datetimepicker.css')}}">
{% endblock %}

{% set active_page = 'dashboard' -%}

{% block content %}
{{super()}}
<div class="container" role="main">
    <h3>Dashboard</h3>
    <div class="container">
        <div class='col-md-3'>
              <div>from:</div>
            <div class="form-group">
                <div class='input-group date' id='dtp_start'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
        <div class='col-md-3'>
            <div>to:</div>
            <div class="form-group">
                <div class='input-group date' id='dtp_end'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
        <div class='col-md-1'>
            <div>&nbsp;</div>
            <!-- http://stackoverflow.com/questions/13437446/how-to-display-selected-item-in-bootstrap-button-dropdown-title -->
            <div class="dropdown">
              <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
                Period: <strong><span class="selection">1 week</span></strong>
                <span class="caret"></span>
              </button>
              <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">1 week</a></li>
                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">1 month</a></li>
                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">1 year</a></li>
                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">all moves</a></li>
              </ul>
            </div>
        </div>
    </div>

    <h3>Totals</h3>
    <table class="table table-striped table-auto-width">
      <tr><th>#Moves</th><td>{{nr_of_moves}}</td></tr>
      {% if nr_of_moves > 0 %}
      <tr><th>Total Distance</th><td>{{macros.format_distance(total_distance)}}</td></tr>
      <tr><th>Total Time</th><td>{{macros.format_duration(total_duration)}}</td></tr>
      <tr><th>Total Ascent</th><td>{{macros.format_hm(total_ascent)}}</td></tr>
      <tr><th>Total Descent</th><td>{{macros.format_hm(total_descent)}}</td></tr>
      {% endif %}
    </table>

    {% if nr_of_moves > 0 %}
    <h3>Activity Totals</h3>
    <div class="col-md-3">
        <table class="table table-hover">
            <thead>
                <tr><th>by Distance</th><th></th></tr>
            </thead>
            <tbody>
                {% for activity in descent_sums.keys() %}
                    <tr><td>{{activity}}</td><td>{{macros.format_distance(distance_sums[activity])}}</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="col-md-3">
        <table class="table table-hover">
            <thead>
                <tr><th>by Duration</th><th></th></tr>
            </thead>
            <tbody>
                {% for activity in duration_sums.keys() %}
                    <tr><td>{{activity}}</td><td>{{macros.format_duration(duration_sums[activity])}}</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="col-md-3">
        <table class="table table-hover">
            <thead>
                <tr><th>by Ascent</th><th></th></tr>
            </thead>
            <tbody>
                {% for activity in ascent_sums.keys() %}
                    <tr><td>{{activity}}</td><td>{{macros.format_hm(ascent_sums[activity])}}</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="col-md-3">
        <table class="table table-hover">
            <thead>
                <tr><th>by Descent</th><th></th></tr>
            </thead>
            <tbody>
                {% for activity in descent_sums.keys() %}
                    <tr><td>{{activity}}</td><td>{{macros.format_hm(descent_sums[activity])}}</td></tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% endif %}
</div>
{% endblock %}
{'fraction_non_alphanumeric': 0.19428499337664795, 'fraction_numerical': 0.007317227023276351, 'mean_word_length': 1.97002622705133, 'pattern_counts': {'":': 8, '<': 387, '<?xml version=': 0, '>': 391, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3678129', 'n_tokens_mistral': 4937, 'n_tokens_neox': 4620, 'n_words': 749}