<commit_before>from flask import Blueprint, render_template, request, redirect, url_for,\
    abort, flash

from sqlalchemy import or_, and_

from datetime import datetime

from viaduct import application, db
from viaduct.helpers import flash_form_errors
from viaduct.models.vacancy import Vacancy
from viaduct.models.company import Company
from viaduct.forms import VacancyForm
from viaduct.api.group import GroupPermissionAPI

blueprint = Blueprint('vacancy', __name__, url_prefix='/vacancies')
FILE_FOLDER = application.config['FILE_DIR']


@blueprint.route('/', methods=['GET', 'POST'])
@blueprint.route('/<int:page>/', methods=['GET', 'POST'])
def view_list(page=1):
    if not GroupPermissionAPI.can_read('vacancy'):
        return abort(403)

    if request.args.get('search') is not None:
        search = request.args.get('search')

        vacancies = Vacancy.query.join(Company).\
            filter(or_(Vacancy.title.like('%' + search + '%'),
                   Company.name.like('%' + search + '%'),
                   Vacancy.workload.like('%' + search + '%'),
                   Vacancy.contract_of_service.like('%' + search + '%'))).\
            order_by(Vacancy.title).order_by(Company.rank)

        if not GroupPermissionAPI.can_write('vacancy'):
            vacancies = vacancies.query.\
                filter(and_(Vacancy.start_date < datetime.utcnow(),
                            Vacancy.end_date >
                            datetime.utcnow())).paginate(page, 15, True)
        else:
            for i, vacancy in enumerate(vacancies):
                print i, vacancy
                if (vacancy.start_date < datetime.date(datetime.utcnow()) and
                        vacancy.end_date < datetime.date(datetime.utcnow())):
                    vacancies[i].expired = True
<commit_msg>vacancy search hotfix<commit_after>from flask import Blueprint, render_template, request, redirect, url_for,\
    abort, flash

from sqlalchemy import or_, and_

from datetime import datetime

from viaduct import application, db
from viaduct.helpers import flash_form_errors
from viaduct.models.vacancy import Vacancy
from viaduct.models.company import Company
from viaduct.forms import VacancyForm
from viaduct.api.group import GroupPermissionAPI

blueprint = Blueprint('vacancy', __name__, url_prefix='/vacancies')
FILE_FOLDER = application.config['FILE_DIR']


@blueprint.route('/', methods=['GET', 'POST'])
@blueprint.route('/<int:page>/', methods=['GET', 'POST'])
def view_list(page=1):
    if not GroupPermissionAPI.can_read('vacancy'):
        return abort(403)

    if request.args.get('search') is not None:
        search = request.args.get('search')

        vacancies = Vacancy.query.join(Company).\
            filter(or_(Vacancy.title.like('%' + search + '%'),
                   Company.name.like('%' + search + '%'),
                   Vacancy.workload.like('%' + search + '%'),
                   Vacancy.contract_of_service.like('%' + search + '%'))).\
            order_by(Vacancy.title).order_by(Company.rank)

        if not GroupPermissionAPI.can_write('vacancy'):
            vacancies = vacancies.\
                filter(and_(Vacancy.start_date < datetime.utcnow(),
                            Vacancy.end_date >
                            datetime.utcnow())).paginate(page, 15, True)
        else:
            for i, vacancy in enumerate(vacancies):
                print i, vacancy
                if (vacancy.start_date < datetime.date(datetime.utcnow()) and
                        vacancy.end_date < datetime.date(datetime.utcnow())):
                    vacancies[i].expired = True

{'fraction_non_alphanumeric': 0.1260341974627689, 'fraction_numerical': 0.003309431880860452, 'mean_word_length': 2.627, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3274931', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1034, 'n_words': 220}