Merge pull request #393 from TheSerapher/issue-392

Fixing issue with delayed inserts for shares
This commit is contained in:
Sebastian Grewe 2013-07-06 14:12:57 -07:00
commit ba8fe0461b
2 changed files with 3 additions and 4 deletions

View File

@ -77,7 +77,7 @@ if (empty($aAllBlocks)) {
foreach ($aAllBlocks as $iIndex => $aBlock) { foreach ($aAllBlocks as $iIndex => $aBlock) {
if (empty($aBlock['share_id'])) { if (empty($aBlock['share_id'])) {
// Fetch this blocks upstream ID // Fetch this blocks upstream ID
if ($share->setUpstream($block->getLastUpstreamId(), $aBlock['time'])) { if ($share->setUpstream($block->getLastUpstreamId())) {
$iCurrentUpstreamId = $share->getUpstreamId(); $iCurrentUpstreamId = $share->getUpstreamId();
$iAccountId = $user->getUserId($share->getUpstreamFinder()); $iAccountId = $user->getUserId($share->getUpstreamFinder());
} else { } else {

View File

@ -177,16 +177,15 @@ class Share {
* @param last int Skips all shares up to last to find new share * @param last int Skips all shares up to last to find new share
* @return bool * @return bool
**/ **/
public function setUpstream($last=0, $time=0) { public function setUpstream($last=0) {
$stmt = $this->mysqli->prepare(" $stmt = $this->mysqli->prepare("
SELECT 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 id > ? AND id > ?
AND UNIX_TIMESTAMP(time) >= ?
ORDER BY id ASC LIMIT 1"); ORDER BY id ASC LIMIT 1");
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $last, $time) && $stmt->execute() && $result = $stmt->get_result()) { if ($this->checkStmt($stmt) && $stmt->bind_param('i', $last) && $stmt->execute() && $result = $stmt->get_result()) {
$this->oUpstream = $result->fetch_object(); $this->oUpstream = $result->fetch_object();
if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id)) if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id))
return true; return true;