mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 03:17:23 +08:00
H&R: add reach by leech time
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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__);
|
||||
|
||||
Reference in New Issue
Block a user