Skip to content

Commit

Permalink
Merge pull request #54 from Hyleus/ratio-preview
Browse files Browse the repository at this point in the history
Display the amount that can still be downloaded.
  • Loading branch information
HDVinnie committed Dec 15, 2017
2 parents d7afbfc + 3dcfb71 commit ff5adc0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Illuminate\Contracts\Auth\CanResetPassword;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use function theodorejb\polycast\to_int;

use App\Helpers\StringHelper;

Expand Down Expand Up @@ -383,6 +384,18 @@ public function ratioAfterSizeString($size, $freeleech = false)
}
}

// Return the size (pretty formated) which can be safely downloaded
// without falling under the minimum ratio.
public function untilRatio($ratio)
{
if ($ratio == 0.0) {
return "";
}

$bytes = to_int($this->uploaded / $ratio);
return StringHelper::formatBytes($bytes);
}

/**
* Returns the HTML of the user's signature
*
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
'results' => 'Results',
'contact' => 'Contact',
'about' => 'About Us',
'community' => 'Community',
'community' => 'Community',
'buffer' => 'Buffer'
];
1 change: 1 addition & 0 deletions resources/views/layout/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
<li><i class="fa fa-arrow-up text-green text-bold"></i> {{ trans('common.upload') }}: {{ Auth::user()->getUploaded() }}</li>
<li><i class="fa fa-arrow-down text-red text-bold"></i> {{ trans('common.download') }}: {{ Auth::user()->getDownloaded() }}</li>
<li><i class="fa fa-signal text-blue text-bold"></i> {{ trans('common.ratio') }}: {{ Auth::user()->getRatioString() }}</li>
<li><i class="fa fa-exchange text-orange text-bold"></i> {{ trans('common.buffer') }}: {{ Auth::user()->untilRatio(config('other.ratio')) }}</li>
<li><i class="fa fa-upload text-green text-bold"></i>
<a href="{{ route('myactive', array('username' => Auth::user()->username, 'id' => Auth::user()->id)) }}" title="My Active Torrents"><span class="text-blue"> Seeding:</span></a> {{ Auth::user()->getSeeding() }}
</li>
Expand Down

0 comments on commit ff5adc0

Please sign in to comment.