Skip to content

Commit

Permalink
Merge pull request #68 from Hyleus/estimated-ratio
Browse files Browse the repository at this point in the history
Improve the estimated ratio for freeleech torrents
  • Loading branch information
HDVinnie committed Dec 22, 2017
2 parents d62338e + 3cd4e6d commit ceabd43
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,10 @@ public function featured()
{
return $this->hasMany(\App\FeaturedTorrent::class);
}

public function isFreeleech($user = null)
{
$pfree = $user ? $user->group->is_freeleech || UserFreeleech::where('user_id', '=', $user->id)->first() : false;
return $this->free || config('other.freeleech') || $pfree;
}
}
2 changes: 1 addition & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function ratioAfterSize($size)
public function ratioAfterSizeString($size, $freeleech = false)
{
if ($freeleech) {
return $this->getRatioString();
return $this->getRatioString() . " (Freeleech)";
}

$ratio = $this->ratioAfterSize($size);
Expand Down
2 changes: 1 addition & 1 deletion resources/views/torrent/torrent.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@

<tr>
<td class="col-sm-2"><strong>Estimated Ratio after Download</strong></td>
<td>{{ $user->ratioAfterSizeString($torrent->size, $torrent->free == "1") }}</td>
<td>{{ $user->ratioAfterSizeString($torrent->size, $torrent->isFreeleech(Auth::user())) }}</td>
</tr>

<tr>
Expand Down

0 comments on commit ceabd43

Please sign in to comment.