Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettify the visible ratio #51

Merged
merged 3 commits into from Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,21 @@ public function getDownloaded($bytes = null, $precision = 2)
*/
public function getRatio()
{
return round($this->uploaded / max(1, $this->downloaded), 2);
if ($this->downloaded == 0) {
return INF;
}
return (float)round($this->uploaded / $this->downloaded, 2);
}

// Return the ratio pretty formated as a string.
public function getRatioString()
{
$ratio = self::getRatio();
if (is_infinite($ratio)) {
return "∞";
} else {
return (string)$ratio;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layout/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
</li>
<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()->getRatio() }}</li>
<li><i class="fa fa-signal text-blue text-bold"></i> {{ trans('common.ratio') }}: {{ Auth::user()->getRatioString() }}</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
2 changes: 1 addition & 1 deletion resources/views/user/profil.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
</tr>
<tr>
<td>Ratio</td>
<td><span class="badge-user group-member">{{ $user->getRatio() }}</span></td>
<td><span class="badge-user group-member">{{ $user->getRatioString() }}</span></td>
</tr>
<tr>
<td>Total Seedtime (All Torrents)</td>
Expand Down