exam support valid multiple

This commit is contained in:
xiaomlove
2022-04-17 16:38:44 +08:00
parent bacfdd0df1
commit e0a515b66c
59 changed files with 950 additions and 79 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
class HitAndRun extends NexusModel
{
protected $table = 'hit_and_runs';
@@ -34,6 +36,20 @@ class HitAndRun extends NexusModel
const MINIMUM_IGNORE_USER_CLASS = User::CLASS_VIP;
protected function seedTimeRequired(): Attribute
{
return new Attribute(
get: fn($value, $attributes) => $this->status == self::STATUS_INSPECTING ? mkprettytime(3600 * Setting::get('hr.seed_time_minimum') - $this->snatch->seedtime) : '---'
);
}
protected function inspectTimeLeft(): Attribute
{
return new Attribute(
get: fn($value, $attributes) => $this->status == self::STATUS_INSPECTING ? mkprettytime(\Carbon\Carbon::now()->diffInSeconds($this->snatch->completedat->addHours(Setting::get('hr.inspect_time')))) : '---'
);
}
public function getStatusTextAttribute()
{
return nexus_trans('hr.status_' . $this->status);

View File

@@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use JetBrains\PhpStorm\Pure;
class Snatch extends NexusModel
{
@@ -33,6 +35,59 @@ class Snatch extends NexusModel
const FINISHED_NO = 'no';
protected function uploadText(): Attribute
{
return new Attribute(
get: fn($value, $attributes) => sprintf('%s@%s', mksize($attributes['uploaded']), $this->getUploadSpeed())
);
}
protected function downloadText(): Attribute
{
return new Attribute(
get: fn($value, $attributes) => sprintf('%s@%s', mksize($attributes['downloaded']), $this->getDownloadSpeed())
);
}
protected function shareRatio(): Attribute
{
return new Attribute(
get: fn($value, $attributes) => $this->getShareRatio()
);
}
public function getUploadSpeed(): string
{
if ($this->seedtime <= 0) {
$speed = mksize(0);
} else {
$speed = mksize($this->uploaded / ($this->seedtime + $this->leechtime));
}
return "$speed/s";
}
public function getDownloadSpeed(): string
{
if ($this->leechtime <= 0) {
$speed = mksize(0);
} else {
$speed = mksize($this->downloaded / $this->leechtime);
}
return "$speed/s";
}
public function getShareRatio()
{
if ($this->downloaded) {
$ratio = floor(($this->uploaded / $this->downloaded) * 1000) / 1000;
} elseif ($this->uploaded) {
$ratio = nexus_trans('snatch.share_ratio_infinity');
} else {
$ratio = '---';
}
return $ratio;
}
public function scopeIsFinished(Builder $builder)
{
return $builder->where('finished', self::FINISHED_YES);

View File

@@ -13,7 +13,7 @@ class Torrent extends NexusModel
'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec',
'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type',
'promotion_until', 'anonymous', 'url', 'pos_state', 'cache_stamp', 'picktype', 'picktime',
'last_reseed', 'pt_gen', 'technical_info'
'last_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders',
];
private static $globalPromotionState;