<commit_before># -*- coding: utf-8 -*-
from flask import Blueprint, render_template, g, redirect, url_for, flash, jsonify, request
from dataviva.apps.general.views import get_locale

from models import SearchQuestion, SearchSelector, SearchProfile
from dataviva import db
from forms import RegistrationForm


mod = Blueprint('search', __name__,
                template_folder='templates',
                url_prefix='/<lang_code>/search')


@mod.before_request
def before_request():
    g.page_type = mod.name


@mod.url_value_preprocessor
def pull_lang_code(endpoint, values):
    g.locale = values.pop('lang_code')


@mod.url_defaults
def add_language_code(endpoint, values):
    values.setdefault('lang_code', get_locale())


@mod.route('/', methods=['GET'])
def index():
    return redirect(url_for('search.admin'))


@mod.route('/question/all', methods=['GET'])
def all_questions():
    result = SearchQuestion.query.all()
    questions = []

    for row in result:
        questions += [(
            row.id,
            SearchProfile.query.filter_by(id=row.profile_id).first_or_404().name(),
            row.description(),
            'a',
            row.answer
        )]
<commit_msg>Adds method to get selectors from database.<commit_after># -*- coding: utf-8 -*-
from flask import Blueprint, render_template, g, redirect, url_for, flash, jsonify, request
from dataviva.apps.general.views import get_locale

from models import SearchQuestion, SearchSelector, SearchProfile
from dataviva import db
from forms import RegistrationForm


mod = Blueprint('search', __name__,
                template_folder='templates',
                url_prefix='/<lang_code>/search')


@mod.before_request
def before_request():
    g.page_type = mod.name


@mod.url_value_preprocessor
def pull_lang_code(endpoint, values):
    g.locale = values.pop('lang_code')


@mod.url_defaults
def add_language_code(endpoint, values):
    values.setdefault('lang_code', get_locale())


@mod.route('/', methods=['GET'])
def index():
    return redirect(url_for('search.admin'))


@mod.route('/selector/all', methods=['GET'])
def all_selectors():
    result = SearchSelector.query.all()
    selectors = []

    for row in result:
        selectors += [(row.id, row.name())]

    return jsonify(selectors=selectors)


@mod.route('/question/all', methods=['GET'])
def all_questions():
    result = SearchQuestion.query.all()
    questions = []

    for row in result:
        questions += [(
            row.id,
            SearchProfile.query.filter_by(id=row.profile_id).first_or_404().name(),
            row.description(),
            'a',
            row.answer
        )]

{'fraction_non_alphanumeric': 0.1322532027128862, 'fraction_numerical': 0.003014318010550113, 'mean_word_length': 3.3739703459637562, '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': '3840553', 'n_tokens_mistral': 811, 'n_tokens_neox': 774, 'n_words': 176}