<commit_before># ！/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2017-2020 Rhilip <<EMAIL>>

import re
import time
from flask import Blueprint, request, jsonify
from app import mysql
from pymysql import escape_string

ptboard_blueprint = Blueprint('ptboard', __name__)


@ptboard_blueprint.route("/ptboard")
def ptboard():
    t0 = time.time()

    search_raw = request.args.get("search") or ""
    order_raw = request.args.get("order") or "desc"
    limit_raw = request.args.get("limit") or 50
    offset_raw = request.args.get("offset") or 0

    search = re.sub(r"[ _\-,.]", " ", search_raw)
    search = search.split()
    search = search[:10]
    if search:
        opt = " AND ".join(["`title` LIKE '%{key}%'".format(key=escape_string(i)) for i in search])
    else:
        opt = "1=1"

    order = "desc" if order_raw not in ["desc", "asc"] else order_raw
    try:
        limit = int(limit_raw)
        if limit > 200:
            limit = 200
    except (ValueError, TypeError):
        limit = 50
    try:
        offset = int(offset_raw)
    except (ValueError, TypeError):
        offset = 0

    sql = ("SELECT * FROM `rss_pt_site` WHERE {opt} ORDER BY `pubDate` {_da} LIMIT {_offset}, {_limit}".format(
        opt=opt, _da=order.upper(), _offset=offset, _limit=limit)
    )
    rows_count, rows_data = mysql.exec(sql=sql, r_dict=True, fetch_all=True, ret_row=True)

    total_data = mysql.exec("SELECT `TABLE_ROWS` FROM `information_schema`.`TABLES` "
                            "WHERE `TABLE_NAME`='rss_pt_site'")[0]

    return jsonify({
        "cost": time.time() - t0,
        "rows": rows_data,
        "total": rows_count if search else total_data
    })
<commit_msg>Fix split mistake.<commit_after># ！/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2017-2020 Rhilip <<EMAIL>>

import re
import time
from flask import Blueprint, request, jsonify
from app import mysql
from pymysql import escape_string

ptboard_blueprint = Blueprint('ptboard', __name__)


@ptboard_blueprint.route("/ptboard")
def ptboard():
    t0 = time.time()

    search_raw = request.args.get("search") or ""
    order_raw = request.args.get("order") or "desc"
    limit_raw = request.args.get("limit") or 50
    offset_raw = request.args.get("offset") or 0

    search = re.sub(r"[ _\-,.+]", " ", search_raw)
    search = search.split()
    search = search[:10]
    if search:
        opt = " AND ".join(["`title` LIKE '%{key}%'".format(key=escape_string(i)) for i in search])
    else:
        opt = "1=1"

    order = "desc" if order_raw not in ["desc", "asc"] else order_raw
    try:
        limit = int(limit_raw)
        if limit > 200:
            limit = 200
    except (ValueError, TypeError):
        limit = 50
    try:
        offset = int(offset_raw)
    except (ValueError, TypeError):
        offset = 0

    sql = ("SELECT * FROM `rss_pt_site` WHERE {opt} ORDER BY `pubDate` {_da} LIMIT {_offset}, {_limit}".format(
        opt=opt, _da=order.upper(), _offset=offset, _limit=limit)
    )
    rows_count, rows_data = mysql.exec(sql=sql, r_dict=True, fetch_all=True, ret_row=True)

    total_data = mysql.exec("SELECT `TABLE_ROWS` FROM `information_schema`.`TABLES` "
                            "WHERE `TABLE_NAME`='rss_pt_site'")[0]

    return jsonify({
        "cost": time.time() - t0,
        "rows": rows_data,
        "total": rows_count if search else total_data
    })

{'fraction_non_alphanumeric': 0.14679976512037582, 'fraction_numerical': 0.017028772753963594, 'mean_word_length': 2.8892694063926943, 'pattern_counts': {'":': 6, '<': 7, '<?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': '213103', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1138, 'n_words': 292}