Example #1
0
function displayRecipe($id)
{
    global $sql;
    $ret = "";
    $q = $sql->prepare("select r.name,r.upc,r.margin,r.price,r.servings,r.current_margin,i.info\n          from recipes as r, info as i where r.id=i.recipeID and r.id=?");
    $r = $sql->execute($q, array($id));
    $w = $sql->fetch_array($r);
    $name = $w['name'];
    $upc = $w['upc'];
    $margin = $w['margin'];
    $price = $w['price'];
    $servings = $w['servings'];
    $current_margin = $w['current_margin'];
    $info = $w['info'];
    $ret .= "<span style=\"font-size: 150%\"><b>{$name}</b></span><br />";
    $ret .= "\n<b>UPC</b>: {$upc}<br />";
    $ret .= "\n<b>Servings</b>: {$servings}<br />";
    $ret .= "<br /><b>Ingredients</b>";
    $ret .= "<div id=recipeingredients>";
    $ret .= getIngredients($id);
    $ret .= "</div>";
    $ret .= "<br /><br /><b>Steps</b>:";
    $ret .= "<div id=recipesteps>";
    $ret .= getSteps($id);
    $ret .= "</div>";
    $ret .= "<br /><br /><b>Info</b>:";
    $ret .= "<div id=infovalue>" . $info . "</div>";
    return $ret;
}
Example #2
0
$count = getCount($conn, $userid);
// streak total
$total = getTotal($conn, $userid);
// get start date
$start = getStart($conn, $userid);
// date = start date
$date = $start;
$todayts = strtotime(date("Y-m-d"));
//$tommrts = strtotime("+1 day", $todayts);
// this is the formatted date for tomorrow: date("Y-m-d", $tommrts);
while (true) {
    $datets = strtotime($date);
    // if date not equal tomorrow's date -- edit: todays date - day not completed
    if ($datets != $todayts) {
        // get day steps
        $steps = getSteps($date, $conn);
        if ($steps >= 7000) {
            // add steps to streak total
            $total = $total + $steps;
            $count++;
            if ($count == 8) {
                $count = 1;
                pointConversion($conn, $total, $userid);
                $total = 0;
            }
        } else {
            $count = 1;
            $total = 0;
        }
    } else {
        // store streak counter and total and update start date
function startTestsInSandcastle($applyDiff, $workflow, $diffID)
{
    // Default options don't terminate on failure, but that's what we want. In
    // the current case we use assertions intentionally as "terminate on failure
    // invariants".
    assert_options(ASSERT_BAIL, true);
    // In case of a diff we'll send notificatios to the author. Else it'll go to
    // the entire team because failures indicate that build quality has regressed.
    $username = $applyDiff ? exec("whoami") : CONT_RUN_ALIAS;
    assert(strlen($username) > 0);
    if ($applyDiff) {
        assert($workflow);
        assert(strlen($diffID) > 0);
        assert(is_numeric($diffID));
    }
    if (strcmp(getenv("ROCKSDB_CHECK_ALL"), 1) == 0) {
        // Extract all tests from the CI definition.
        $output = file_get_contents("build_tools/rocksdb-lego-determinator");
        assert(strlen($output) > 0);
        preg_match_all('/[ ]{2}([a-zA-Z0-9_]+)[\\)]{1}/', $output, $matches);
        $tests = $matches[1];
        assert(count($tests) > 0);
    } else {
        // Manually list of tests we want to run in Sandcastle.
        $tests = array("unit", "unit_481", "clang_unit", "tsan", "asan", "lite_test", "valgrind", "release");
    }
    $send_email_template = array('type' => 'email', 'triggers' => array('fail'), 'emails' => array($username . '@fb.com'));
    // Construct a job definition for each test and add it to the master plan.
    foreach ($tests as $test) {
        $stepName = "RocksDB diff " . $diffID . " test " . $test;
        if (!$applyDiff) {
            $stepName = "RocksDB continuous integration test " . $test;
        }
        $arg[] = array("name" => $stepName, "report" => array($send_email_template), "steps" => getSteps($applyDiff, $diffID, $username, $test));
    }
    // We cannot submit the parallel execution master plan to Sandcastle and
    // need supply the job plan as a determinator. So we construct a small job
    // that will spit out the master job plan which Sandcastle will parse and
    // execute. Why compress the job definitions? Otherwise we run over the max
    // string size.
    $cmd = "echo " . base64_encode(json_encode($arg)) . " | gzip -f | base64 -w0";
    assert(strlen($cmd) > 0);
    $arg_encoded = shell_exec($cmd);
    assert(strlen($arg_encoded) > 0);
    $runName = "Run diff " . $diffID . "for user " . $username;
    if (!$applyDiff) {
        $runName = "RocksDB continuous integration build and test run";
    }
    $command = array("name" => $runName, "steps" => array());
    $command["steps"][] = array("name" => "Generate determinator", "shell" => "echo " . $arg_encoded . " | base64 --decode | gzip -d" . " | base64 --decode", "determinator" => true, "user" => "root");
    // Submit to Sandcastle.
    $url = 'https://interngraph.intern.facebook.com/sandcastle/generate?' . 'command=SandcastleUniversalCommand' . '&vcs=rocksdb-git&revision=origin%2Fmaster&type=lego' . '&user='******'&alias=rocksdb-precommit' . '&command-args=' . urlencode(json_encode($command));
    // Fetch the configuration necessary to submit a successful HTTPS request.
    $sandcastle_config = getSandcastleConfig();
    $app = $sandcastle_config[0];
    $token = $sandcastle_config[1];
    $cmd = 'https_proxy= HTTPS_PROXY= curl -s -k -F app=' . $app . ' ' . '-F token=' . $token . ' "' . $url . '"';
    $output = shell_exec($cmd);
    assert(strlen($output) > 0);
    // Extract Sandcastle URL from the response.
    preg_match('/url": "(.+)"/', $output, $sandcastle_url);
    assert(count($sandcastle_url) > 0, "Unable to submit Sandcastle request.");
    assert(strlen($sandcastle_url[1]) > 0, "Unable to extract Sandcastle URL.");
    if ($applyDiff) {
        echo "\nSandcastle URL: " . $sandcastle_url[1] . "\n";
        // Ask Phabricator to display it on the diff UI.
        postURL($diffID, $sandcastle_url[1]);
    } else {
        echo "Continuous integration started Sandcastle tests. You can look at ";
        echo "the progress at:\n" . $sandcastle_url[1] . "\n";
    }
}
Example #4
0
function displayRecipe($id)
{
    global $sql;
    $ret = "";
    $q = $sql->prepare("select r.name,r.upc,r.margin,r.price,r.servings,r.shelflife,r.current_margin,i.info,\n          c.name as category\n          from recipes as r, info as i, categories as c\n           where r.id=i.recipeID and c.id=r.categoryID and r.id=?");
    $r = $sql->execute($q, array($id));
    $w = $sql->fetch_array($r);
    $name = $w['name'];
    $upc = $w['upc'];
    $margin = $w['margin'];
    $price = $w['price'];
    $servings = $w['servings'];
    $shelflife = $w['shelflife'];
    $current_margin = $w['current_margin'];
    $info = $w['info'];
    $category = $w['category'];
    $ret .= "<input type=hidden id=recipeID value=\"{$id}\" />";
    $ret .= "<b>Name</b>: <span id=recipename> {$name} ";
    $ret .= "<a href=\"\" onClick=\"editRecipeField('name'); return false;\">";
    $ret .= "<img src='images/b_edit.png'></a> ";
    $ret .= "<input type=hidden id=hrecipename value=\"{$name}\" /></span>";
    $ret .= "<a href=\"\" onClick=\"deleteRecipe('{$name}'); return false;\">";
    $ret .= "<img src='images/b_drop.png'></a><br />";
    $ret .= "<b>Category</b>: <span id=recipecategory> {$category} ";
    $ret .= "<a href=\"\" onClick=\"changeCategory('{$category}'); return false;\">";
    $ret .= "<img src='images/b_edit.png'></a> ";
    $ret .= "</span><br />";
    $ret .= "\n<b>UPC</b>: <span id=recipeupc> {$upc} ";
    $ret .= "<a href=\"\" onClick=\"editRecipeField('upc'); return false;\">";
    $ret .= "<img src='images/b_edit.png'></a> ";
    $ret .= "<input type=hidden id=hrecipeupc value=\"{$upc}\" /></span><br />";
    $ret .= "<div id=recipeprice><b>Price</b>: {$price} ";
    $ret .= "<a href=\"\" onclick=\"editPrice(); return false;\">";
    $ret .= "<img src='images/b_edit.png'></a> ";
    $ret .= "<input type=hidden id=hrecipeprice value=\"{$price}\" /></div>";
    $ret .= "\n<b>Servings</b>: <span id=recipeservings> {$servings} ";
    $ret .= "<a href=\"\" onClick=\"editRecipeField('servings'); return false;\">";
    $ret .= "<img src='images/b_edit.png'></a> ";
    $ret .= "<input type=hidden id=hrecipeservings value=\"{$servings}\" /></span><br />";
    $ret .= "\n<b>Shelf Life</b>: <span id=recipeshelflife> {$shelflife} ";
    $ret .= "<a href=\"\" onClick=\"editRecipeField('shelflife'); return false;\">";
    $ret .= "<img src='images/b_edit.png'></a> ";
    $ret .= "<input type=hidden id=hrecipeshelflife value=\"{$shelflife}\" /></span><br />";
    $ret .= "\n<b>Desired Margin</b>: <span id=recipemargin> {$margin}  ";
    $ret .= "<a href=\"\" onClick=\"editRecipeField('margin'); return false;\">";
    $ret .= "<img src='images/b_edit.png'></a> ";
    $ret .= "<input type=hidden id=hrecipemargin value=\"{$margin}\" /></span><br />";
    $ret .= "<div id=recipecurrentmargin>";
    if ($current_margin < $margin) {
        $ret .= currentMarginDiv($current_margin, '#bb0000');
    } else {
        $ret .= currentMarginDiv($current_margin, '#00bb00');
    }
    $ret .= "</div>";
    $ret .= "<br /><b>Ingredients</b>";
    $ret .= "<div id=recipeingredients>";
    $ret .= getIngredients($id);
    $ret .= "</div>";
    $ret .= "( <a href=\"\" onClick=\"addIngredient(); return false;\">New ingredient</a> ) ";
    $ret .= "( <a href=\"\" onclick=\"addLabel(); return false;\">New label</a> )";
    $ret .= "<br /><br /><b>Steps</b>:";
    $ret .= "<div id=recipesteps>";
    $ret .= getSteps($id);
    $ret .= "</div>";
    $ret .= "( <a href=\"\" onClick=\"addStep(); return false;\">New step</a> )";
    $ret .= "<br /><br /><b>Info</b>:";
    $ret .= "<div id=recipeinfo>";
    $ret .= "<div id=infovalue>" . $info . "</div>";
    $ret .= "<br />( <a href=\"\" onClick=\"editInfo({$id}); return false;\"><img src='images/b_edit.png'></a> )";
    $ret .= "</div>";
    $ret .= "<br /><b>Status</b>: ";
    $ret .= "<span id=recipestatus>";
    $ret .= getStatus($id);
    $ret .= "</span> ";
    $ret .= "[ <a href=\"\" onclick=\"restatus({$id}); return false;\">Refresh</a> ]";
    return $ret;
}
Example #5
0
function displayRecipe($id)
{
    global $sql;
    $ret = "";
    $q = $sql->prepare("select r.name,r.upc,r.margin,r.price,r.servings,r.current_margin,i.info\n          from recipes as r, info as i where r.id=i.recipeID and r.id=?");
    $r = $sql->execute($q, array($id));
    $w = $sql->fetch_array($r);
    $name = $w['name'];
    $upc = $w['upc'];
    $margin = $w['margin'];
    $price = $w['price'];
    $servings = $w['servings'];
    $current_margin = $w['current_margin'];
    $info = $w['info'];
    $ret .= "<b>Name</b>: {$name}<br />";
    $ret .= "\n<b>UPC</b>: {$upc}<br />";
    $ret .= "<div id=recipeprice><b>Price</b>: {$price}</div>";
    $ret .= "\n<b>Servings</b>: {$servings}<br />";
    $ret .= "<b>Multiplier</b>: <input type=text value=1 id=multiplier size=3 /> ";
    $ret .= "<a href=\"\" onclick=\"mult({$id}); return false;\">Change</a> | ";
    $ret .= "<a href=\"print.php?id={$id}\" target=\"print_window\">Print</a><br />";
    $ret .= "<br /><b>Ingredients</b>";
    $ret .= "<div id=recipeingredients>";
    $ret .= getIngredients($id);
    $ret .= "</div>";
    $ret .= "<br /><br /><b>Steps</b>:";
    $ret .= "<div id=recipesteps>";
    $ret .= getSteps($id);
    $ret .= "</div>";
    $ret .= "<br /><br /><b>Info</b>:";
    $ret .= "<div id=infovalue>" . $info . "</div>";
    return $ret;
}