bonus show counts + size + A value and fix H&R stats

This commit is contained in:
xiaomlove
2022-10-12 19:37:02 +08:00
parent 46aaf2d7b7
commit 0a9f3e4e14
7 changed files with 41 additions and 13 deletions

View File

@@ -386,6 +386,7 @@ class HitAndRunRepository extends BaseRepository
$sql = "select hit_and_runs.status, count(*) as counts from hit_and_runs where uid = $uid group by status";
}
$results = NexusDB::select($sql);
do_log("user: $uid, sql: $sql, results: " . json_encode($results));
if (!$formatted) {
return $results;
}
@@ -406,12 +407,16 @@ class HitAndRunRepository extends BaseRepository
}
return implode(" ", $out);
} else {
$grouped = [];
foreach ($results as $item) {
$grouped[$item['status']] = $item['counts'];
}
foreach (SearchBox::listSections() as $key => $info) {
if ($key == SearchBox::SECTION_BROWSE) {
return sprintf(
'%s/%s/%s',
$results[HitAndRun::STATUS_INSPECTING] ?? 0,
$results[HitAndRun::STATUS_UNREACHED] ?? 0,
$grouped[HitAndRun::STATUS_INSPECTING] ?? 0,
$grouped[HitAndRun::STATUS_UNREACHED] ?? 0,
HitAndRun::getConfig('ban_user_when_counts_reach', $info['mode'])
);
}

View File

@@ -5867,8 +5867,8 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
$timenow = time();
$sectoweek = 7*24*60*60;
$A = 0;
$count = $torrent_peer_count = 0;
$A = $official_a = $size = $official_size = 0;
$count = $torrent_peer_count = $official_torrent_peer_count = 0;
$logPrefix = "[CALCULATE_SEED_BONUS], uid: $uid, torrentIdArr: " . json_encode($torrentIdArr);
if ($torrentIdArr !== null) {
if (empty($torrentIdArr)) {
@@ -5893,9 +5893,9 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
$zeroBonusTag = \App\Models\Setting::get('bonus.zero_bonus_tag');
$zeroBonusFactor = \App\Models\Setting::get('bonus.zero_bonus_factor');
do_log("$logPrefix, sql: $sql, count: " . count($torrentResult) . ", officialTag: $officialTag, officialAdditionalFactor: $officialAdditionalFactor, zeroBonusTag: $zeroBonusTag, zeroBonusFactor: $zeroBonusFactor");
$official_a = 0;
foreach ($torrentResult as $torrent)
{
$size = bcadd($size, $torrent['size']);
$weeks_alive = ($timenow - strtotime($torrent['added'])) / $sectoweek;
$gb_size = $gb_size_raw = $torrent['size'] / 1073741824;
if ($zeroBonusTag && isset($tagGrouped[$torrent['id']][$zeroBonusTag]) && is_numeric($zeroBonusFactor)) {
@@ -5908,6 +5908,8 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
$officialAIncrease = 0;
if ($officialTag && isset($tagGrouped[$torrent['id']][$officialTag])) {
$officialAIncrease = $temp;
$official_torrent_peer_count++;
$official_size = bcadd($official_size, $torrent['size']);
}
$official_a += $officialAIncrease;
do_log(sprintf(
@@ -5920,7 +5922,10 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
$seed_bonus = $seed_points = $valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count);
//Official addition don't think about the minimum value
$official_bonus = $valuetwo * atan($official_a / $l_bonus);
$result = compact('seed_points','seed_bonus', 'A', 'count', 'torrent_peer_count', 'official_a', 'official_bonus');
$result = compact(
'seed_points','seed_bonus', 'A', 'count', 'torrent_peer_count', 'size',
'official_bonus', 'official_a', 'official_torrent_peer_count', 'official_size'
);
$result['donor_times'] = $donortimes_bonus;
$result['official_additional_factor'] = $officialAdditionalFactor;
do_log("$logPrefix, result: " . json_encode($result));

View File

@@ -867,8 +867,8 @@ function getDataTraffic(array $torrent, array $queries, array $user, $peer, $sna
throw new \InvalidArgumentException("user no '__is_donor' field");
}
$log = sprintf(
"torrent: %s, user: %s, peerUploaded: %s, peerDownloaded: %s, queriesUploaded: %s, queriesDownloaded: %s",
$torrent['id'], $user['id'], $peer['uploaded'] ?? '', $peer['downloaded'] ?? '', $queries['uploaded'], $queries['downloaded']
"torrent: %s, owner: %s, user: %s, peerUploaded: %s, peerDownloaded: %s, queriesUploaded: %s, queriesDownloaded: %s",
$torrent['id'], $torrent['owner'], $user['id'], $peer['uploaded'] ?? '', $peer['downloaded'] ?? '', $queries['uploaded'], $queries['downloaded']
);
if (!empty($peer)) {
$realUploaded = max(bcsub($queries['uploaded'], $peer['uploaded']), 0);
@@ -930,7 +930,7 @@ function getDataTraffic(array $torrent, array $queries, array $user, $peer, $sna
*/
$isSeedBoxRuleEnabled = get_setting('seed_box.enabled') == 'yes';
$log .= ", isSeedBoxRuleEnabled: $isSeedBoxRuleEnabled, user class: {$user['class']}, __is_donor: {$user['__is_donor']}";
if ($isSeedBoxRuleEnabled && !($user['class'] >= \App\Models\User::CLASS_VIP || $user['__is_donor'])) {
if ($isSeedBoxRuleEnabled && $torrent['owner'] != $user['id'] && !($user['class'] >= \App\Models\User::CLASS_VIP || $user['__is_donor'])) {
$isIPSeedBox = isIPSeedBox($queries['ip'], $user['id']);
$log .= ", isIPSeedBox: $isIPSeedBox";
if ($isIPSeedBox) {

View File

@@ -153,6 +153,9 @@ $lang_mybonus = array
'harem_additional_desc' => '后宫只考虑直属后宫。每个后宫加成值可<a href="invite.php?id=%s" target="_blank" class="altlink">在此</a>查看',
'harem_additional_factor' => '所得奖励为全部后宫的时魔(不考虑加成)之和,乘以后宫加成系数,当前值为:',
'text_bonus_summary' => '每小时获得的合计魔力值',
'col_count' => '数量',
'col_size' => '体积',
'col_a' => 'A 值',
);
?>

View File

@@ -153,6 +153,9 @@ $lang_mybonus = array
'harem_additional_desc' => '後宮只考慮直屬後宮。每個後宮加成值可<a href="invite.php?id=%s" target="_blank" class="altlink">在此</a>查看',
'harem_additional_factor' => '所得獎勵為全部後宮的時魔(不考慮加成)之和,乘以後宮加成系數,當前值為:',
'text_bonus_summary' => '每小時獲得的合計魔力值',
'col_count' => '數量',
'col_size' => '體積',
'col_a' => 'A 值',
);
?>

View File

@@ -153,6 +153,9 @@ where<ul><li><b>A</b> is an intermediate variable</li><li><b>Ti</b> is the <b>i<
'harem_additional_desc' => "Only direct harems will be considered for the harem. Each harem's bonus addition value can be viewed <a href=\"invite.php?id=%s\" class='altlink' target='_blank'>here</a>",
'harem_additional_factor' => 'The reward obtained is the sum of the hourly bonus of all the harems (regardless of the addition), multiplied by the harem bonus factor, with the current value of ',
'text_bonus_summary' => 'Total bonus gained per hour',
'col_count' => 'Counts',
'col_size' => 'Size',
'col_a' => 'A Value',
);
?>

View File

@@ -461,10 +461,13 @@ if ($officialAdditionalFactor > 0 && $officialTag) {
$hasOfficialAddition = true;
}
$summaryTable = '<table cellspacing="4" cellpadding="4" style="width: 50%"><tbody>';
$summaryTable .= '<tr style="font-weight: bold"><td>'.$lang_mybonus['reward_type'].'</td><td>'.$lang_mybonus['bonus_base'].'</td><td>'.$lang_mybonus['factor'].'</td><td>'.$lang_mybonus['got_bonus'].'</td><td>'.$lang_mybonus['total'].'</td></tr>';
$summaryTable .= '<tr style="font-weight: bold"><td>'.$lang_mybonus['reward_type'].'</td><td>'.$lang_mybonus['col_count'].'</td><td>'.$lang_mybonus['col_size'].'</td><td>'.$lang_mybonus['col_a'].'</td><td>'.$lang_mybonus['bonus_base'].'</td><td>'.$lang_mybonus['factor'].'</td><td>'.$lang_mybonus['got_bonus'].'</td><td>'.$lang_mybonus['total'].'</td></tr>';
$summaryTable .= sprintf(
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td rowspan="%s">%s</td></tr>',
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td rowspan="%s">%s</td></tr>',
$lang_mybonus['reward_type_basic'],
$seedBonusResult['torrent_peer_count'],
mksize($seedBonusResult['size']),
$seedBonusResult['A'],
number_format($seedBonusResult['seed_bonus'],3),
$baseBonusFactor,
number_format($baseBonus,3),
@@ -479,8 +482,11 @@ if ($hasOfficialAddition) {
print("<li>".$lang_mybonus['official_tag_bonus_additional_factor'].$officialAdditionalFactor."</li>");
print("</ul>");
$summaryTable .= sprintf(
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
$lang_mybonus['reward_type_official_addition'],
$seedBonusResult['official_torrent_peer_count'],
mksize($seedBonusResult['official_size']),
$seedBonusResult['official_a'],
number_format($seedBonusResult['official_bonus'], 3),
$officialAdditionalFactor,
number_format($seedBonusResult['official_bonus'] * $officialAdditionalFactor, 3)
@@ -494,8 +500,11 @@ if ($hasHaremAddition) {
print("<li>".$lang_mybonus['harem_additional_factor'].$haremFactor."</li>");
print("</ul>");
$summaryTable .= sprintf(
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
$lang_mybonus['reward_type_harem_addition'],
'--',
'--',
'--',
number_format($haremAddition, 3),
$haremFactor,
number_format($haremAddition * $haremFactor, 3)