<commit_before>"""
Debug Blueprints.
"""
from flask import Blueprint, current_app, redirect, jsonify, url_for, request

debug_pages = Blueprint('debug', __name__)


@debug_pages.route("/clear_all", methods=['GET', 'POST'])
def clear_all():
    if request.method == 'GET':
        return '<form method="POST"><input type="submit" value="CLEAR DATABASE"></form>'
    else:
        mongo = current_app.mongo
        mongo.db.userSessions.remove()
        mongo.db.interactionSessions.remove()
        return redirect(url_for('end_session'))


@debug_pages.route("/dump")
def dump_session():
    mongo = current_app.mongo
    return jsonify({
        'userSessions': list(mongo.db.userSessions.find()),
        'interactionSessions': list(mongo.db.interactionSessions.find()),
    })<commit_msg>Add session id to debug dump<commit_after>"""
Debug Blueprints.
"""
from flask import Blueprint, current_app, redirect, jsonify, url_for, request
from usersession import get_session_id

debug_pages = Blueprint('debug', __name__)


@debug_pages.route("/clear_all", methods=['GET', 'POST'])
def clear_all():
    if request.method == 'GET':
        return '<form method="POST"><input type="submit" value="CLEAR DATABASE"></form>'
    else:
        mongo = current_app.mongo
        mongo.db.userSessions.remove()
        mongo.db.interactionSessions.remove()
        return redirect(url_for('end_session'))


@debug_pages.route("/dump")
def dump_session():
    mongo = current_app.mongo
    return jsonify({
        "session['session_id']": get_session_id(),
        'userSessions': list(mongo.db.userSessions.find()),
        'interactionSessions': list(mongo.db.interactionSessions.find()),
    })
{'fraction_non_alphanumeric': 0.14937759336099585, 'fraction_numerical': 0.0, 'mean_word_length': 4.146341463414634, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 9, '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': '891458', 'n_tokens_mistral': 532, 'n_tokens_neox': 523, 'n_words': 105}