mirror of
https://github.com/friendica/friendica
synced 2025-04-23 20:30:10 +00:00
We now incrementally calculate the queue delivery time
This commit is contained in:
parent
06bce464ba
commit
d70a20a466
5 changed files with 32 additions and 36 deletions
|
@ -19,7 +19,22 @@ class Queue
|
|||
public static function updateTime($id)
|
||||
{
|
||||
logger('queue: requeue item ' . $id);
|
||||
dba::update('queue', ['last' => DateTimeFormat::utcNow()], ['id' => $id]);
|
||||
$queue = dba::selectFirst('queue', ['retrial'], ['id' => $id]);
|
||||
if (!DBM::is_result($queue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$retrial = $queue['retrial'];
|
||||
|
||||
if ($retrial > 14) {
|
||||
self::removeItem($id);
|
||||
}
|
||||
|
||||
// Calculate the delay until the next trial
|
||||
$delay = (($retrial + 3) ** 4) + (rand(1, 30) * ($retrial + 1));
|
||||
$next = DateTimeFormat::utc(date('c', time() + $delay));
|
||||
|
||||
dba::update('queue', ['last' => DateTimeFormat::utcNow(), 'retrial' => $retrial + 1, 'next' => $next], ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue