<commit_before><?php
require '../util.php';

function summa($type)
{
    $query = "
        SELECT SUM(amount) AS sum
        FROM purses
        WHERE type='$type'
        ";
    $result = do_query($query);
    $row = get_row($result);
    $v = $row['sum'];

    $query = "
        SELECT SUM(amount) AS sum
        FROM orderbook
        WHERE type='$type' AND status='OPEN'
        ";
    $result = do_query($query);
    $row = get_row($result);
    $v += $row['sum'];

    $query = "
        SELECT SUM(amount) AS sum
        FROM requests
        WHERE curr_type='$type' AND req_type='WITHDR' AND status='VERIFY'
        ";
    $result = do_query($query);
    $row = get_row($result);
    $v += $row['sum'];
    return $v;
}

echo "BTC = " . summa('BTC') . "\n";    
echo "GBP = " . summa('GBP') . "\n";    
?>
<commit_msg>check for mismatch between deposits and actual balances.<commit_after><?php
require '../util.php';

function summa($type)
{
    $query = "
        SELECT SUM(amount) AS sum
        FROM purses
        WHERE type='$type'
        ";
    $result = do_query($query);
    $row = get_row($result);
    $v = $row['sum'];

    $query = "
        SELECT SUM(amount) AS sum
        FROM orderbook
        WHERE type='$type' AND status='OPEN'
        ";
    $result = do_query($query);
    $row = get_row($result);
    $v += $row['sum'];

    $query = "
        SELECT SUM(amount) AS sum
        FROM requests
        WHERE curr_type='$type' AND req_type='WITHDR' AND status='VERIFY'
        ";
    $result = do_query($query);
    $row = get_row($result);
    $v += $row['sum'];

    $query = "
        SELECT SUM(amount) AS sum
        FROM requests
        WHERE curr_type='$type' AND req_type='DEPOS' AND status='FINAL'
        ";
    $result = do_query($query);
    $row = get_row($result);
    $u = $row['sum'];
    echo "$type = $v\t  $u\n";
    if ($u != $v)
        echo "*********** MISMATCH ****************\n";
}

summa('BTC');    
summa('GBP');    
?>

{'fraction_non_alphanumeric': 0.18576476527006563, 'fraction_numerical': 0.0, 'mean_word_length': 2.196774193548387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '565315', 'n_tokens_mistral': 690, 'n_tokens_neox': 671, 'n_words': 160}