fixed repeating smartblock to not overflow time limit
This commit is contained in:
parent
6031d95351
commit
74cd668301
1 changed files with 11 additions and 3 deletions
|
@ -1355,14 +1355,22 @@ SQL;
|
||||||
$sizeOfInsert = count($insertList);
|
$sizeOfInsert = count($insertList);
|
||||||
|
|
||||||
// if block is not full and repeat_track is check, fill up more
|
// if block is not full and repeat_track is check, fill up more
|
||||||
|
// additionally still don't overflow the limit
|
||||||
while (!$isBlockFull && $repeat == 1 && $sizeOfInsert > 0) {
|
while (!$isBlockFull && $repeat == 1 && $sizeOfInsert > 0) {
|
||||||
Logging::debug("adding repeated tracks.");
|
Logging::debug("adding repeated tracks.");
|
||||||
Logging::debug("total time = " . $totalTime);
|
Logging::debug("total time = " . $totalTime);
|
||||||
|
|
||||||
$randomEleKey = array_rand(array_slice($insertList, 0, $sizeOfInsert));
|
$randomEleKey = array_rand(array_slice($insertList, 0, $sizeOfInsert));
|
||||||
$insertList[] = $insertList[$randomEleKey];
|
|
||||||
$totalTime += $insertList[$randomEleKey]['length'];
|
$projectedTime = $totalTime + $insertList[$randomEleKey]['length'];
|
||||||
$totalItems++;
|
if ($projectedTime > $limit['time']) {
|
||||||
|
$totalItems++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$insertList[] = $insertList[$randomEleKey];
|
||||||
|
$totalTime += $insertList[$randomEleKey]['length'];
|
||||||
|
$totalItems++;
|
||||||
|
}
|
||||||
|
|
||||||
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
|
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue