H&R, VIP or above ignore it

This commit is contained in:
xiaomlove
2022-02-23 21:17:25 +08:00
parent 5b82aa78c5
commit e2f30ecf0c
5 changed files with 35 additions and 18 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ class Test extends Command
public function handle() public function handle()
{ {
$rep = new HitAndRunRepository(); $rep = new HitAndRunRepository();
$r = $rep->getStatusStats(1)->get(2); $r = $rep->cronjobUpdateStatus();
dd($r); dd($r);
} }
+31 -17
View File
@@ -35,7 +35,7 @@ class HitAndRunRepository extends BaseRepository
->with([ ->with([
'torrent' => function ($query) {$query->select(['id', 'size', 'name']);}, 'torrent' => function ($query) {$query->select(['id', 'size', 'name']);},
'snatch', 'snatch',
'user' => function ($query) {$query->select(['id', 'username', 'lang']);}, 'user' => function ($query) {$query->select(['id', 'username', 'lang', 'class']);},
'user.language', 'user.language',
]); ]);
if (!is_null($uid)) { if (!is_null($uid)) {
@@ -69,6 +69,15 @@ class HitAndRunRepository extends BaseRepository
continue; continue;
} }
//If is VIP or above, pass
if ($row->user->class >= User::CLASS_VIP) {
$result = $this->reachedBySpecialUserClass($row);
if ($result) {
$successCounts++;
}
continue;
}
//check seed time //check seed time
$targetSeedTime = $row->snatch->seedtime; $targetSeedTime = $row->snatch->seedtime;
$requireSeedTime = bcmul($setting['seed_time_minimum'], 3600); $requireSeedTime = bcmul($setting['seed_time_minimum'], 3600);
@@ -130,21 +139,9 @@ class HitAndRunRepository extends BaseRepository
'ignore_when_ratio_reach' => Setting::get('hr.ignore_when_ratio_reach'), 'ignore_when_ratio_reach' => Setting::get('hr.ignore_when_ratio_reach'),
], $hitAndRun->user->locale); ], $hitAndRun->user->locale);
$update = [ $update = [
'status' => HitAndRun::STATUS_REACHED,
'comment' => $comment 'comment' => $comment
]; ];
$affectedRows = DB::table($hitAndRun->getTable()) return $this->inspectingToReached($hitAndRun, $update, __FUNCTION__);
->where('id', $hitAndRun->id)
->where('status', HitAndRun::STATUS_INSPECTING)
->update($update);
do_log("[H&R_REACHED_BY_SHARE_RATIO], " . last_query() . ", affectedRows: $affectedRows");
if ($affectedRows != 1) {
do_log($hitAndRun->toJson() . ", [H&R_REACHED_BY_SHARE_RATIO], affectedRows != 1, skip!", 'notice');
return false;
}
$message = $this->geReachedMessage($hitAndRun);
Message::query()->insert($message);
return true;
} }
private function reachedBySeedTime(HitAndRun $hitAndRun): bool private function reachedBySeedTime(HitAndRun $hitAndRun): bool
@@ -156,16 +153,33 @@ class HitAndRunRepository extends BaseRepository
'seed_time_minimum' => Setting::get('hr.seed_time_minimum') 'seed_time_minimum' => Setting::get('hr.seed_time_minimum')
], $hitAndRun->user->locale); ], $hitAndRun->user->locale);
$update = [ $update = [
'status' => HitAndRun::STATUS_REACHED,
'comment' => $comment 'comment' => $comment
]; ];
return $this->inspectingToReached($hitAndRun, $update, __FUNCTION__);
}
private function reachedBySpecialUserClass(HitAndRun $hitAndRun): bool
{
do_log(__METHOD__);
$comment = nexus_trans('hr.reached_by_special_user_class_comment', [
'user_class_text' => $hitAndRun->user->class_text,
], $hitAndRun->user->locale);
$update = [
'comment' => $comment
];
return $this->inspectingToReached($hitAndRun, $update, __FUNCTION__);
}
private function inspectingToReached(HitAndRun $hitAndRun, array $update, string $logPrefix = ''): bool
{
$update['status'] = HitAndRun::STATUS_REACHED;
$affectedRows = DB::table($hitAndRun->getTable()) $affectedRows = DB::table($hitAndRun->getTable())
->where('id', $hitAndRun->id) ->where('id', $hitAndRun->id)
->where('status', HitAndRun::STATUS_INSPECTING) ->where('status', HitAndRun::STATUS_INSPECTING)
->update($update); ->update($update);
do_log("[H&R_REACHED_BY_SEED_TIME], " . last_query() . ", affectedRows: $affectedRows"); do_log("[$logPrefix], " . last_query() . ", affectedRows: $affectedRows");
if ($affectedRows != 1) { if ($affectedRows != 1) {
do_log($hitAndRun->toJson() . ", [H&R_REACHED_BY_SEED_TIME], affectedRows != 1, skip!", 'notice'); do_log($hitAndRun->toJson() . ", [$logPrefix], affectedRows != 1, skip!", 'notice');
return false; return false;
} }
$message = $this->geReachedMessage($hitAndRun); $message = $this->geReachedMessage($hitAndRun);
+1
View File
@@ -12,6 +12,7 @@ return [
'reached_by_seed_time_comment' => 'Up to:nowseed time: :seed_time Hour(s) reached :seed_time_minimum Hour(s)', 'reached_by_seed_time_comment' => 'Up to:nowseed time: :seed_time Hour(s) reached :seed_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_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, ignore this H&R",
'reached_message_subject' => 'H&R(ID: :hit_and_run_id) reached!', 'reached_message_subject' => 'H&R(ID: :hit_and_run_id) reached!',
'reached_message_content' => 'Congratulation! The torrent: :torrent_name(ID: :torrent_id) you download at: :completed_at has reach the requirement.', 'reached_message_content' => 'Congratulation! The torrent: :torrent_name(ID: :torrent_id) you download at: :completed_at has reach the requirement.',
+1
View File
@@ -12,6 +12,7 @@ return [
'reached_by_seed_time_comment' => '截止::now,做种时间: :seed_time Hour(s) 已达标 :seed_time_minimum Hour(s)', 'reached_by_seed_time_comment' => '截止::now,做种时间: :seed_time Hour(s) 已达标 :seed_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_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) 已达标!', 'reached_message_subject' => 'H&R(ID: :hit_and_run_id) 已达标!',
'reached_message_content' => '你于 :completed_at 下载完成的种子::torrent_name(ID: :torrent_id) H&R 已达标,恭喜!', 'reached_message_content' => '你于 :completed_at 下载完成的种子::torrent_name(ID: :torrent_id) H&R 已达标,恭喜!',
+1
View File
@@ -12,6 +12,7 @@ return [
'reached_by_seed_time_comment' => '截止::now,做種時間: :seed_time Hour(s) 已達標 :seed_time_minimum Hour(s)', 'reached_by_seed_time_comment' => '截止::now,做種時間: :seed_time Hour(s) 已達標 :seed_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_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) 已達標!', 'reached_message_subject' => 'H&R(ID: :hit_and_run_id) 已達標!',
'reached_message_content' => '你於 :completed_at 下載完成的種子::torrent_name(ID: :torrent_id) H&R 已達標,恭喜!', 'reached_message_content' => '你於 :completed_at 下載完成的種子::torrent_name(ID: :torrent_id) H&R 已達標,恭喜!',