H&R: add reach by leech time

This commit is contained in:
xiaomlove
2025-07-18 12:17:15 +07:00
parent 0cf44d26af
commit 84b554f102
9 changed files with 39 additions and 1 deletions

View File

@@ -212,6 +212,7 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
Forms\Components\Radio::make('hr.mode')->options(HitAndRun::listModes(true))->inline(true)->label(__('label.setting.hr.mode')),
Forms\Components\TextInput::make('hr.inspect_time')->helperText(__('label.setting.hr.inspect_time_help'))->label(__('label.setting.hr.inspect_time'))->integer(),
Forms\Components\TextInput::make('hr.seed_time_minimum')->helperText(__('label.setting.hr.seed_time_minimum_help'))->label(__('label.setting.hr.seed_time_minimum'))->integer(),
Forms\Components\TextInput::make('hr.leech_time_minimum')->helperText(__('label.setting.hr.leech_time_minimum_help'))->label(__('label.setting.hr.leech_time_minimum'))->integer(),
Forms\Components\TextInput::make('hr.ignore_when_ratio_reach')->helperText(__('label.setting.hr.ignore_when_ratio_reach_help'))->label(__('label.setting.hr.ignore_when_ratio_reach'))->integer(),
Forms\Components\TextInput::make('hr.ban_user_when_counts_reach')->helperText(__('label.setting.hr.ban_user_when_counts_reach_help'))->label(__('label.setting.hr.ban_user_when_counts_reach'))->integer(),
Forms\Components\TextInput::make('hr.include_rate')->helperText(__('label.setting.hr.include_rate_help'))->label(__('label.setting.hr.include_rate'))->numeric(),

View File

@@ -202,6 +202,20 @@ class HitAndRunRepository extends BaseRepository
continue;
}
//check leech time
if (isset($setting['leech_time_minimum']) && $setting['leech_time_minimum'] > 0) {
$targetLeechTime = $row->snatch->leechtime;
$requireLeechTime = bcmul($setting['leech_time_minimum'], 3600);
do_log("$currentLog, targetLeechTime: $targetLeechTime, requireLeechTime: $requireLeechTime");
if ($targetLeechTime >= $requireLeechTime) {
$result = $this->reachedByLeechTime($row, $setting);
if ($result) {
$successCounts++;
}
continue;
}
}
//check share ratio
$targetShareRatio = bcdiv($row->snatch->uploaded, $row->torrent->size, 4);
$requireShareRatio = $setting['ignore_when_ratio_reach'];
@@ -273,6 +287,20 @@ class HitAndRunRepository extends BaseRepository
return $this->inspectingToReached($hitAndRun, $update, __FUNCTION__);
}
private function reachedByLeechTime(HitAndRun $hitAndRun, array $setting): bool
{
do_log(__METHOD__);
$comment = nexus_trans('hr.reached_by_leech_time_comment', [
'now' => Carbon::now()->toDateTimeString(),
'leech_time' => bcdiv($hitAndRun->snatch->leechtime, 3600, 1),
'leech_time_minimum' => $setting['leech_time_minimum'],
], $hitAndRun->user->locale);
$update = [
'comment' => $comment
];
return $this->inspectingToReached($hitAndRun, $update, __FUNCTION__);
}
private function reachedBySpecialUserClass(HitAndRun $hitAndRun): bool
{
do_log(__METHOD__);

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.7');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-07-14');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-07-18');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -11,6 +11,7 @@ return [
'mode_' . \App\Models\HitAndRun::MODE_GLOBAL => 'Global',
'reached_by_seed_time_comment' => 'Up to:nowseed time: :seed_time Hour(s) reached :seed_time_minimum Hour(s)',
'reached_by_leech_time_comment' => 'Up to:nowleech time: :leech_time Hour(s) reached :leech_time_minimum Hour(s)',
'reached_by_share_ratio_comment' => "Up to:now \nseed time: :seed_time Hour(s) Unreached :seed_time_minimum Hour(s) \nShare ratio: :share_ratio reached standard:ignore_when_ratio_reach",
'reached_by_special_user_class_comment' => "Your user class: :user_class_text or donated user, ignore this H&R",
'reached_message_subject' => 'H&R(ID: :hit_and_run_id) reached!',

View File

@@ -82,6 +82,8 @@ return [
'inspect_time_help' => 'The duration of the examination is calculated from the completion of the download, in hours',
'seed_time_minimum' => 'Seed time minimum',
'seed_time_minimum_help' => 'The shortest time to do the seeds to meet the standard, in hours, must be less than the length of the expedition',
'leech_time_minimum' => 'Leech time minimum',
'leech_time_minimum_help' => 'The minimum download time required to meet the standard, in hours, must be less than the length of the expedition. Set to 0 to disable',
'ignore_when_ratio_reach' => 'Achievement Sharing Rate',
'ignore_when_ratio_reach_help' => 'The minimum sharing rate to meet the standard',
'ban_user_when_counts_reach' => 'H&R counts limit',

View File

@@ -11,6 +11,7 @@ return [
'mode_' . \App\Models\HitAndRun::MODE_GLOBAL => '全局',
'reached_by_seed_time_comment' => '截止::now做种时间: :seed_time Hour(s) 已达标 :seed_time_minimum Hour(s)',
'reached_by_leech_time_comment' => '截止::now下载时间: :leech_time Hour(s) 已达标 :leech_time_minimum Hour(s)',
'reached_by_share_ratio_comment' => "截止::now \n做种时间: :seed_time Hour(s) 未达标 :seed_time_minimum Hour(s) \n分享率: :share_ratio 达忽略标准::ignore_when_ratio_reach",
'reached_by_special_user_class_comment' => "你是::user_class_text 或捐赠用户,无视此 H&R",
'reached_message_subject' => 'H&R(ID: :hit_and_run_id) 已达标!',

View File

@@ -82,6 +82,8 @@ return [
'inspect_time_help' => '考察时长自下载完成后开始计算,单位:小时',
'seed_time_minimum' => '达标做种时长',
'seed_time_minimum_help' => '达标的最短做种时长,单位:小时,必须小于考察时长',
'leech_time_minimum' => '达标下载时长',
'leech_time_minimum_help' => '达标的最短下载时长,单位:小时,必须小于考察时长。设置为 0 不启用',
'ignore_when_ratio_reach' => '达标分享率',
'ignore_when_ratio_reach_help' => '达标的最小分享率',
'ban_user_when_counts_reach' => 'H&R 数量上限',

View File

@@ -11,6 +11,7 @@ return [
'mode_' . \App\Models\HitAndRun::MODE_GLOBAL => '全局',
'reached_by_seed_time_comment' => '截止::now做種時間: :seed_time Hour(s) 已達標 :seed_time_minimum Hour(s)',
'reached_by_leech_time_comment' => '截止::now下載時間: :leech_time Hour(s) 已達標 :leech_time_minimum Hour(s)',
'reached_by_share_ratio_comment' => "截止::now \n做種時間: :seed_time Hour(s) 未達標 :seed_time_minimum Hour(s) \n分享率: :share_ratio 達忽略標準::ignore_when_ratio_reach",
'reached_by_special_user_class_comment' => "你是::user_class_text 或捐贈用戶,無視此 H&R",
'reached_message_subject' => 'H&R(ID: :hit_and_run_id) 已達標!',

View File

@@ -82,6 +82,8 @@ return [
'inspect_time_help' => '考察時長自下載完成後開始計算,單位:小時',
'seed_time_minimum' => '達標做種時長',
'seed_time_minimum_help' => '達標的最短做種時長,單位:小時,必須小於考察時長',
'leech_time_minimum' => '達標下載時長',
'leech_time_minimum_help' => '達標的最短下載時長,單位:小時,必須小於考察時長。設置爲 0 不啓用',
'ignore_when_ratio_reach' => '達標分享率',
'ignore_when_ratio_reach_help' => '達標的最小分享率',
'ban_user_when_counts_reach' => 'H&R 數量上限',