<commit_before>from mongoengine import *
from docdef import *
from flask import Flask, render_template, redirect, url_for
from flask.ext.mongoengine import MongoEngine
from flask_bootstrap import Bootstrap
from flask_debugtoolbar import DebugToolbarExtension

from collections import defaultdict
import time

app = Flask(__name__)
app.config['MONGODB_DB'] = 'yoda'
app.debug = True
app.config['SECRET_KEY'] = "<KEY>"

app.config['DEBUG_TB_PANELS'] = [
    'flask_debugtoolbar.panels.versions.VersionDebugPanel',
    'flask_debugtoolbar.panels.timer.TimerDebugPanel',
    'flask_debugtoolbar.panels.headers.HeaderDebugPanel',
    'flask_debugtoolbar.panels.request_vars.RequestVarsDebugPanel',
    'flask_debugtoolbar.panels.template.TemplateDebugPanel',
    #'flask_debugtoolbar.panels.sqlalchemy.SQLAlchemyDebugPanel',
    'flask_debugtoolbar.panels.logger.LoggingPanel',
    'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel',
    # Add the MongoDB panel
    'flask_debugtoolbar_mongo.panel.MongoDebugPanel',
]

toolbar = DebugToolbarExtension(app)

db = MongoEngine(app)
Bootstrap(app)

@app.route("/")
def index():
    return render_template('index.html', files=File.objects.exclude("lines", "content").order_by('-timestamp'))

@app.route("/view_file/<file_id>")
def view_file(file_id):

    list_var_value = []
    series = defaultdict(list)

    for file in File.objects(id=file_id):
        for line in file.lines:
            for data in line.data:
                for var_and_value in data:
                    list_var_value.append(var_and_value)

    for k,v in list_var_value: series[k].append(v)

    return render_template('view_file.html', files=File.objects(id=file_id), series=series.items())
<commit_msg>Removing one useless query<commit_after>from mongoengine import *
from docdef import *
from flask import Flask, render_template, redirect, url_for
from flask.ext.mongoengine import MongoEngine
from flask_bootstrap import Bootstrap
from flask_debugtoolbar import DebugToolbarExtension

from collections import defaultdict

app = Flask(__name__)
app.config['MONGODB_DB'] = 'yoda'
app.debug = True
app.config['SECRET_KEY'] = "<KEY>"

app.config['DEBUG_TB_PANELS'] = [
    'flask_debugtoolbar.panels.versions.VersionDebugPanel',
    'flask_debugtoolbar.panels.timer.TimerDebugPanel',
    'flask_debugtoolbar.panels.headers.HeaderDebugPanel',
    'flask_debugtoolbar.panels.request_vars.RequestVarsDebugPanel',
    'flask_debugtoolbar.panels.template.TemplateDebugPanel',
    #'flask_debugtoolbar.panels.sqlalchemy.SQLAlchemyDebugPanel',
    'flask_debugtoolbar.panels.logger.LoggingPanel',
    'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel',
    # Add the MongoDB panel
    'flask_debugtoolbar_mongo.panel.MongoDebugPanel',
]

toolbar = DebugToolbarExtension(app)

db = MongoEngine(app)
Bootstrap(app)

@app.route("/")
def index():
    return render_template('index.html', files=File.objects.exclude("lines", "content").order_by('-timestamp'))

@app.route("/view_file/<file_id>")
def view_file(file_id):

    list_var_value = []
    series = defaultdict(list)
    file_object = File.objects(id=file_id)

    for file in file_object:
        for line in file.lines:
            for data in line.data:
                for var_and_value in data:
                    list_var_value.append(var_and_value)

    for k,v in list_var_value: series[k].append(v)

    return render_template('view_file.html', files=file_object, series=series.items())

{'fraction_non_alphanumeric': 0.10915898617511521, 'fraction_numerical': 0.0, 'mean_word_length': 4.846801346801347, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '708265', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1109, 'n_words': 197}