<commit_before># -*- coding: utf-8 -*-
"""
Defines views.
"""

import calendar
from flask import redirect, url_for
from flask.ext.mako import render_template

from presence_analyzer.main import app
from presence_analyzer.utils import (
    jsonify,
    get_data,
    get_user_additional_data,
    mean,
    group_by_weekday,
    group_by_weekday_start_end)

import logging
log = logging.getLogger(__name__)  # pylint: disable=C0103


@app.route('/')
def mainpage():
    """
    Redirects to front page.
    """
    return redirect(url_for('presence_weekday_view'))


@app.route('/presence_weekday.html')
def presence_weekday_view():
    """
    Renders presence weekday view.
    """
    return render_template('presence_weekday.html')


@app.route('/presence_mean_time.html')
def presence_mean_time_view():
    """
    Renders mean time view.
    """
    return render_template('presence_mean_time.html')


@app.route('/presence_start_end.html')
def presence_start_end_view():
    """
    Renders presence start end view.
    """
    return render_template('presence_start_end.html')


@app.route('/api/v1/users', methods=['GET'])
@jsonify
def users_view():
    """
    Users listing for dropdown.
    """
    data = get_data()
    additional_data = get_user_additional_data()

    return [
        {
            'user_id': i,
            'name': additional_data[str(i)]["name"],
            'avatar': additional_data[str(i)]["url"],
        }
        for i in data.keys() if str(i) in additional_data
    ]


@app.route('/api/v1/mean_time_weekday/', methods=['GET'])
@app.route('/api/v1/mean_time_weekday/<int:user_id>', methods=['GET'])
@jsonify
def mean_time_weekday_api_view(user_id):<commit_msg>api now returns aplhabetically sorted data<commit_after># -*- coding: utf-8 -*-
"""
Defines views.
"""

import calendar
from flask import redirect, url_for
from flask.ext.mako import render_template

from presence_analyzer.main import app
from presence_analyzer.utils import (
    jsonify,
    get_data,
    get_user_additional_data,
    mean,
    group_by_weekday,
    group_by_weekday_start_end)

import logging
log = logging.getLogger(__name__)  # pylint: disable=C0103


@app.route('/')
def mainpage():
    """
    Redirects to front page.
    """
    return redirect(url_for('presence_weekday_view'))


@app.route('/presence_weekday.html')
def presence_weekday_view():
    """
    Renders presence weekday view.
    """
    return render_template('presence_weekday.html')


@app.route('/presence_mean_time.html')
def presence_mean_time_view():
    """
    Renders mean time view.
    """
    return render_template('presence_mean_time.html')


@app.route('/presence_start_end.html')
def presence_start_end_view():
    """
    Renders presence start end view.
    """
    return render_template('presence_start_end.html')


@app.route('/api/v1/users', methods=['GET'])
@jsonify
def users_view():
    """
    Users listing for dropdown.
    """
    data = get_data()
    additional_data = get_user_additional_data()

    result = [
        {
            'user_id': i,
            'name': additional_data[str(i)]["name"],
            'avatar': additional_data[str(i)]["url"],
        }
        for i in data.keys() if str(i) in additional_data
    ]
    result = sorted(result, key=lambda x: x["name"])
    return result


@app.route('/api/v1/mean_time_weekday/', methods=['GET'])
@app.route('/api/v1/mean_time_weekday/<int:user_id>', methods=['GET'])
@jsonify
def mean_time_weekday_api_view(user_id):
{'fraction_non_alphanumeric': 0.1389840182648402, 'fraction_numerical': 0.0045662100456621, 'mean_word_length': 3.630118890356671, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4714984', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1168, 'n_words': 225}