<commit_before>#!/usr/bin/env python
import argparse
import json
import os
import random

from flask import Flask, make_response, render_template
from pymongo import MongoClient

import models
import settings
import utils

app = Flask(__name__)

@app.route('/')
def index():
    if settings.VOTING:

        sessions = utils.connect('session').find({})
        payload = []

        for s in sessions:
            s = dict(s)
            user = utils.connect('user').find_one({"_id": s['user']})
            s['username'] = user['name']
            payload.append(s)

        # random.shuffle(payload)

        return render_template('session_list.html', sessions=payload, VOTING=settings.VOTING)

    else:
        return render_template('create_session.html', VOTING=settings.VOTING);


@app.route('/api/vote/action/')
def vote_action(methods=['GET']):
    from flask import request
    session = request.args.get('session')
    user = request.args.get('user')

    error = json.dumps({"success": False, "text": "Please send a session ID and a user ID."})

    if not session or not user:
        return error

    u = utils.connect('user').find_one({"_id": user})
    if not u:
        return error

    # s = utils.connect('session').find_one({"_id": session})
    # if not s:<commit_msg>Fix0ring.<commit_after>#!/usr/bin/env python
import argparse
import json
import os
import random

from flask import Flask, make_response, render_template
from pymongo import MongoClient

import models
import settings
import utils

app = Flask(__name__)

@app.route('/')
def index():
    if settings.VOTING:

        sessions = utils.connect('session').find({})
        payload = []

        for s in sessions:
            s = dict(s)
            user = utils.connect('user').find_one({"_id": s['user']})
            s['username'] = user['name']
            payload.append(s)

        random.shuffle(payload)

        return render_template('session_list.html', sessions=payload, VOTING=settings.VOTING)

    else:
        return render_template('create_session.html', VOTING=settings.VOTING);


@app.route('/api/vote/action/')
def vote_action(methods=['GET']):
    from flask import request
    session = request.args.get('session')
    user = request.args.get('user')

    error = json.dumps({"success": False, "text": "Please send a session ID and a user ID."})

    if not session or not user:
        return error

    u = utils.connect('user').find_one({"_id": user})
    if not u:
        return error

    # s = utils.connect('session').find_one({"_id": session})
    # if not s:
{'fraction_non_alphanumeric': 0.13809154383242825, 'fraction_numerical': 0.0003878975950349108, 'mean_word_length': 3.035993740219092, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, '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': '1800472', 'n_tokens_mistral': 804, 'n_tokens_neox': 781, 'n_words': 205}