Ejemplo n.º 1
0
function reCategorize($argv)
{
    global $pdo;
    $where = '';
    $othercats = Category::getCategoryOthersGroup();
    $update = true;
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $where = ' AND group_id = ' . $argv[1];
    } else {
        if (isset($argv[1]) && preg_match('/\\([\\d, ]+\\)/', $argv[1])) {
            $where = ' AND group_id IN ' . $argv[1];
        } else {
            if (isset($argv[1]) && $argv[1] === 'misc') {
                $where = sprintf(' AND categoryid IN (%s)', $othercats);
            }
        }
    }
    if (isset($argv[2]) && $argv[2] === 'test') {
        $update = false;
    }
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1]))) {
        echo $pdo->log->header("Categorizing all releases in {$argv[1]} using searchname. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] == "misc") {
            echo $pdo->log->header("Categorizing all releases in misc categories using searchname. This can take a while, be patient.");
        } else {
            echo $pdo->log->header("Categorizing all releases using searchname. This can take a while, be patient.");
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1])) || $argv[1] === 'misc') {
        $chgcount = categorizeRelease(str_replace(" AND", "WHERE", $where), $update, true);
    } else {
        $chgcount = categorizeRelease('', $update, true);
    }
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $time = $consoletools->convertTime(TIME() - $timestart);
    if ($update === true) {
        echo $pdo->log->header("Finished re-categorizing " . number_format($chgcount) . " releases in " . $time . " , using the searchname.\n");
    } else {
        echo $pdo->log->header("Finished re-categorizing in " . $time . " , using the searchname.\n" . "This would have changed " . number_format($chgcount) . " releases but no updates were done.\n");
    }
}
Ejemplo n.º 2
0
function reCategorize($argv)
{
    $c = new ColorCLI();
    $where = '';
    $update = true;
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $where = ' AND groupid = ' . $argv[1];
    } else {
        if (isset($argv[1]) && preg_match('/\\([\\d, ]+\\)/', $argv[1])) {
            $where = ' AND groupid IN ' . $argv[1];
        } else {
            if (isset($argv[1]) && $argv[1] === 'misc') {
                $where = ' AND categoryid IN (1090, 2020, 3050, 4040, 5050, 6050, 7050, 8010)';
            }
        }
    }
    if (isset($argv[2]) && $argv[2] === 'test') {
        $update = false;
    }
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1]))) {
        echo $c->header("Categorizing all releases in {$argv[1]} using searchname. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] == "misc") {
            echo $c->header("Categorizing all releases in misc categories using searchname. This can take a while, be patient.");
        } else {
            echo $c->header("Categorizing all releases using searchname. This can take a while, be patient.");
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1])) || $argv[1] === 'misc') {
        $chgcount = categorizeRelease($update, str_replace(" AND", "WHERE", $where), true);
    } else {
        $chgcount = categorizeRelease($update, "", true);
    }
    $consoletools = new ConsoleTools();
    $time = $consoletools->convertTime(TIME() - $timestart);
    if ($update === true) {
        echo $c->header("Finished re-categorizing " . number_format($chgcount) . " releases in " . $time . " , \tusing the searchname.\n");
    } else {
        echo $c->header("Finished re-categorizing in " . $time . " , using the searchname.\n" . "This would have changed " . number_format($chgcount) . " releases but no updates were done.\n");
    }
}