<commit_before><?php
/**
 * Perform a search
 *
 * @url         $URL$
 * @date        $Date$
 * @version     $Revision$
 * @author      $Author$
 *
 * @package     Beirdobot
 *
/**/

// Search string
    isset($_GET['s']) or $_GET['s'] = $_POST['s'];

// Our time division (15 minute blocks)
    $division = 15 * 60;

// Build the query
    $params = array($_GET['s'], $_GET['s']);
    $query  = "SELECT chanid,
                      $division * FLOOR(MIN(timestamp) / $division) AS starttime,
                      SUM(MATCH(nick, message) AGAINST (?)) AS score
                 FROM irclog
                WHERE msgtype IN (0, 1)
                      AND MATCH(nick, message) AGAINST (?) > 0";

// Extra parameters
    if (!empty($_GET['chanid'])) {
        $query   .= ' AND chanid=?';
        $params[] = intVal($_GET['chanid']);
    }

// Extra parameters
    if (!empty($_GET['starttime'])) {
        $query   .= ' AND timestamp>=?';
        $params[] = strtotime($_GET['starttime']);
    }
// Extra parameters
    if (!empty($_GET['endtime'])) {
        $query   .= ' AND timestamp>=?';
        $params[] = strtotime($_GET['endtime']);
    }

// Finish building the query
    $query .= " GROUP BY chanid, $division * FLOOR(timestamp / $division)
                ORDER BY score DESC, msgid ASC
                   LIMIT 100";

/**
 * @global  array    $GLOBALS['Results']
 * @name    $Results
/**/
    $Results = array();

// Start the timer
    $search_time = microtime_float();

// Run the query and gather the results
    $sh = $db->query($query, $params);
    while ($row = $sh->fetch_assoc()) {
        $row['channel']        = &$Channels[$row['chanid']];
        $row['server']         = &$row['channel']->server;
        $row['endtime']        = $row['starttime'] + $division;
        $row['link_starttime'] = $row['starttime'] - intVal($division / 2);
        $row['link_endtime']   = $row['starttime'] + intVal($division / 2);
        $Results[] = $row;
    }
    $sh->finish();

// How long
    $search_time = microtime_float() - $search_time;

// Print the page<commit_msg>round the search timer because PHP uses like 11 digits for floats<commit_after><?php
/**
 * Perform a search
 *
 * @url         $URL$
 * @date        $Date$
 * @version     $Revision$
 * @author      $Author$
 *
 * @package     Beirdobot
 *
/**/

// Search string
    isset($_GET['s']) or $_GET['s'] = $_POST['s'];

// Our time division (15 minute blocks)
    $division = 15 * 60;

// Build the query
    $params = array($_GET['s'], $_GET['s']);
    $query  = "SELECT chanid,
                      $division * FLOOR(MIN(timestamp) / $division) AS starttime,
                      SUM(MATCH(nick, message) AGAINST (?)) AS score
                 FROM irclog
                WHERE msgtype IN (0, 1)
                      AND MATCH(nick, message) AGAINST (?) > 0";

// Extra parameters
    if (!empty($_GET['chanid'])) {
        $query   .= ' AND chanid=?';
        $params[] = intVal($_GET['chanid']);
    }

// Extra parameters
    if (!empty($_GET['starttime'])) {
        $query   .= ' AND timestamp>=?';
        $params[] = strtotime($_GET['starttime']);
    }
// Extra parameters
    if (!empty($_GET['endtime'])) {
        $query   .= ' AND timestamp>=?';
        $params[] = strtotime($_GET['endtime']);
    }

// Finish building the query
    $query .= " GROUP BY chanid, $division * FLOOR(timestamp / $division)
                ORDER BY score DESC, msgid ASC
                   LIMIT 100";

/**
 * @global  array    $GLOBALS['Results']
 * @name    $Results
/**/
    $Results = array();

// Start the timer
    $search_time = microtime_float();

// Run the query and gather the results
    $sh = $db->query($query, $params);
    while ($row = $sh->fetch_assoc()) {
        $row['channel']        = &$Channels[$row['chanid']];
        $row['server']         = &$row['channel']->server;
        $row['endtime']        = $row['starttime'] + $division;
        $row['link_starttime'] = $row['starttime'] - intVal($division / 2);
        $row['link_endtime']   = $row['starttime'] + intVal($division / 2);
        $Results[] = $row;
    }
    $sh->finish();

// How long
    $search_time = round(microtime_float() - $search_time, 4) + 0;

// Print the page
{'fraction_non_alphanumeric': 0.18417333961375412, 'fraction_numerical': 0.007536504945831371, 'mean_word_length': 2.17176997759522, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '4190520', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1320, 'n_words': 326}