get both valid and invalid round shares
This commit is contained in:
parent
8b8166bea7
commit
9bf99e3c8e
@ -31,45 +31,57 @@ class Share {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getRoundShares() {
|
public function getRoundShares() {
|
||||||
$stmt = $this->mysqli->prepare("SELECT count(id) AS total FROM $this->table WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0)");
|
$stmt = $this->mysqli->prepare("
|
||||||
|
SELECT
|
||||||
|
( SELECT IFNULL(count(id), 0)
|
||||||
|
FROM $this->table
|
||||||
|
WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0)
|
||||||
|
AND our_result = 'Y' ) as valid,
|
||||||
|
( SELECT IFNULL(count(id), 0)
|
||||||
|
FROM $this->table
|
||||||
|
WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0)
|
||||||
|
AND our_result = 'N' ) as invalid
|
||||||
|
");
|
||||||
|
echo $this->mysqli->error;
|
||||||
if ($this->checkStmt($stmt)) {
|
if ($this->checkStmt($stmt)) {
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
return $result->fetch_object()->total;
|
return $result->fetch_assoc();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSharesForAccounts($previous_upstream=0, $current_upstream) {
|
public function getSharesForAccounts($previous_upstream=0, $current_upstream) {
|
||||||
$stmt = $this->mysqli->prepare("SELECT
|
$stmt = $this->mysqli->prepare("SELECT
|
||||||
a.id,
|
a.id,
|
||||||
validT.account AS username,
|
validT.account AS username,
|
||||||
sum(validT.valid) as valid,
|
sum(validT.valid) as valid,
|
||||||
IFNULL(sum(invalidT.invalid),0) as invalid
|
IFNULL(sum(invalidT.invalid),0) as invalid
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
SUBSTRING_INDEX( `username` , '.', 1 ) as account,
|
SUBSTRING_INDEX( `username` , '.', 1 ) as account,
|
||||||
COUNT(id) AS valid
|
COUNT(id) AS valid
|
||||||
FROM $this->table
|
FROM $this->table
|
||||||
WHERE id BETWEEN ? AND ?
|
WHERE id BETWEEN ? AND ?
|
||||||
AND our_result = 'Y'
|
AND our_result = 'Y'
|
||||||
GROUP BY account
|
GROUP BY account
|
||||||
) validT
|
) validT
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
(
|
(
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
SUBSTRING_INDEX( `username` , '.', 1 ) as account,
|
SUBSTRING_INDEX( `username` , '.', 1 ) as account,
|
||||||
COUNT(id) AS invalid
|
COUNT(id) AS invalid
|
||||||
FROM $this->table
|
FROM $this->table
|
||||||
WHERE id BETWEEN ? AND ?
|
WHERE id BETWEEN ? AND ?
|
||||||
AND our_result = 'N'
|
AND our_result = 'N'
|
||||||
GROUP BY account
|
GROUP BY account
|
||||||
) invalidT
|
) invalidT
|
||||||
ON validT.account = invalidT.account
|
ON validT.account = invalidT.account
|
||||||
INNER JOIN accounts a ON a.username = validT.account
|
INNER JOIN accounts a ON a.username = validT.account
|
||||||
GROUP BY a.username DESC");
|
GROUP BY a.username DESC");
|
||||||
if ($this->checkStmt($stmt)) {
|
if ($this->checkStmt($stmt)) {
|
||||||
$stmt->bind_param('iiii', $previous_upstream, $current_upstream, $previous_upstream, $current_upstream);
|
$stmt->bind_param('iiii', $previous_upstream, $current_upstream, $previous_upstream, $current_upstream);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@ -82,9 +94,9 @@ class Share {
|
|||||||
|
|
||||||
public function moveArchive($previous_upstream=0, $current_upstream,$block_id) {
|
public function moveArchive($previous_upstream=0, $current_upstream,$block_id) {
|
||||||
$archive_stmt = $this->mysqli->prepare("INSERT INTO shares_archive (share_id, username, our_result, upstream_result, block_id)
|
$archive_stmt = $this->mysqli->prepare("INSERT INTO shares_archive (share_id, username, our_result, upstream_result, block_id)
|
||||||
SELECT id, username, our_result, upstream_result, ?
|
SELECT id, username, our_result, upstream_result, ?
|
||||||
FROM $this->table
|
FROM $this->table
|
||||||
WHERE id BETWEEN ? AND ?");
|
WHERE id BETWEEN ? AND ?");
|
||||||
$delete_stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE id BETWEEN ? AND ?");
|
$delete_stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE id BETWEEN ? AND ?");
|
||||||
if ($this->checkStmt($archive_stmt) && $this->checkStmt($delete_stmt)) {
|
if ($this->checkStmt($archive_stmt) && $this->checkStmt($delete_stmt)) {
|
||||||
$archive_stmt->bind_param('iii', $block_id, $previous_upstream, $current_upstream);
|
$archive_stmt->bind_param('iii', $block_id, $previous_upstream, $current_upstream);
|
||||||
@ -112,11 +124,11 @@ class Share {
|
|||||||
}
|
}
|
||||||
public function setUpstream($time='') {
|
public function setUpstream($time='') {
|
||||||
$stmt = $this->mysqli->prepare("SELECT
|
$stmt = $this->mysqli->prepare("SELECT
|
||||||
SUBSTRING_INDEX( `username` , '.', 1 ) AS account, id
|
SUBSTRING_INDEX( `username` , '.', 1 ) AS account, id
|
||||||
FROM $this->table
|
FROM $this->table
|
||||||
WHERE upstream_result = 'Y'
|
WHERE upstream_result = 'Y'
|
||||||
AND UNIX_TIMESTAMP(time) BETWEEN ? AND (? + 1)
|
AND UNIX_TIMESTAMP(time) BETWEEN ? AND (? + 1)
|
||||||
ORDER BY id ASC LIMIT 1");
|
ORDER BY id ASC LIMIT 1");
|
||||||
if ($this->checkStmt($stmt)) {
|
if ($this->checkStmt($stmt)) {
|
||||||
$stmt->bind_param('ii', $time, $time);
|
$stmt->bind_param('ii', $time, $time);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user