mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
add seed_points_per_hour + improve calculateUserSeedBonus
This commit is contained in:
+6
-22
@@ -300,28 +300,12 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
// }
|
||||
|
||||
//chunk async
|
||||
$asyncTaskCount = 3;
|
||||
$baseDuration = floor($autoclean_interval_one / ($asyncTaskCount + 1));
|
||||
$delayBase = 0;
|
||||
$requestId = nexus()->getRequestId();
|
||||
$maxUidRes = mysql_fetch_assoc(sql_query("select max(id) as max_uid from users limit 1"));
|
||||
$maxUid = $maxUidRes['max_uid'];
|
||||
$chunk = 1000;
|
||||
$beginUid = 0;
|
||||
$chunkCounts = ceil($maxUid / $chunk);
|
||||
$delay = ceil($baseDuration/$chunkCounts);
|
||||
$i = 0;
|
||||
do_log("autoclean_interval_one: $autoclean_interval_one, baseDuration: $baseDuration, maxUid: $maxUid, chunk: $chunk, chunkCounts: $chunkCounts, delayBase: $delayBase, delay: $delay");
|
||||
do {
|
||||
$command = sprintf(
|
||||
'cleanup --action=seed_bonus --begin_id=%s --end_id=%s --request_id=%s --delay=%s',
|
||||
$beginUid, $beginUid + $chunk, $requestId, $delayBase + $i * $delay
|
||||
);
|
||||
$output = executeCommand($command, 'string', true);
|
||||
do_log(sprintf('command: %s, output: %s', $command, $output));
|
||||
$beginUid += $chunk;
|
||||
$i++;
|
||||
} while ($beginUid < $maxUid);
|
||||
$command = sprintf(
|
||||
'cleanup --action=seed_bonus --begin_id=%s --end_id=%s --request_id=%s --delay=%s',
|
||||
0, 0, nexus()->getRequestId(), 0
|
||||
);
|
||||
$output = executeCommand($command, 'string', true);
|
||||
do_log(sprintf('command: %s, output: %s', $command, $output));
|
||||
|
||||
$log = 'calculate seeding bonus';
|
||||
do_log($log);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.5');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-07-10');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-07-12');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
+18
-10
@@ -6075,18 +6075,26 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
|
||||
|
||||
function calculate_harem_addition($uid)
|
||||
{
|
||||
$harems = \App\Models\User::query()
|
||||
->where('invited_by', $uid)
|
||||
// $harems = \App\Models\User::query()
|
||||
// ->where('invited_by', $uid)
|
||||
// ->where('status', \App\Models\User::STATUS_CONFIRMED)
|
||||
// ->where('enabled', \App\Models\User::ENABLED_YES)
|
||||
// ->get(['id']);
|
||||
// $addition = 0;
|
||||
// $haremsCount = $harems->count();
|
||||
// foreach ($harems as $harem) {
|
||||
// $result = calculate_seed_bonus($harem->id);
|
||||
// $addition += $result['seed_points'];
|
||||
// }
|
||||
// do_log("[HAREM_ADDITION], user: $uid, haremsCount: $haremsCount ,addition: $addition");
|
||||
|
||||
$addition = \Nexus\Database\NexusDB::table("users")
|
||||
->where("invited_by", $uid)
|
||||
->where('status', \App\Models\User::STATUS_CONFIRMED)
|
||||
->where('enabled', \App\Models\User::ENABLED_YES)
|
||||
->get(['id']);
|
||||
$addition = 0;
|
||||
$haremsCount = $harems->count();
|
||||
foreach ($harems as $harem) {
|
||||
$result = calculate_seed_bonus($harem->id);
|
||||
$addition += $result['seed_points'];
|
||||
}
|
||||
do_log("[HAREM_ADDITION], user: $uid, haremsCount: $haremsCount ,addition: $addition");
|
||||
->sum("seed_points_per_hour")
|
||||
;
|
||||
do_log("[HAREM_ADDITION], user: $uid, addition: $addition");
|
||||
return $addition;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user