Merge pull request #4169 from Roardom/profile-client-seedsize

(Add) Client torrent size sum to profile page
This commit is contained in:
HDVinnie
2024-11-20 22:32:37 -05:00
committed by GitHub
2 changed files with 11 additions and 1 deletions
+7 -1
View File
@@ -94,8 +94,14 @@ class UserController extends Controller
// 'boughtDownload' => BonTransactions::where('sender_id', '=', $user->id)->where([['name', 'like', '%Download%']])->sum('cost'),
'invitedBy' => Invite::where('accepted_by', '=', $user->id)->first(),
'clients' => $user->peers()
->join('torrents', 'torrents.id', '=', 'peers.torrent_id')
->select('agent', 'port')
->selectRaw('INET6_NTOA(ip) as ip, MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as num_peers, MAX(connectable) as connectable')
->selectRaw('INET6_NTOA(peers.ip) as ip')
->selectRaw('MIN(peers.created_at) as created_at')
->selectRaw('MAX(peers.updated_at) as updated_at')
->selectRaw('SUM(torrents.size) as size')
->selectRaw('COUNT(*) as num_peers')
->selectRaw('MAX(peers.connectable) as connectable')
->groupBy(['ip', 'port', 'agent'])
->where('active', '=', true)
->get(),
@@ -256,6 +256,7 @@
<th>{{ __('torrent.started') }}</th>
<th>{{ __('torrent.last-update') }}</th>
<th>{{ __('torrent.peers') }}</th>
<th>{{ __('torrent.size') }}</th>
@if (\config('announce.connectable_check') === true)
<th>Connectable</th>
@endif
@@ -300,6 +301,9 @@
{{ $client->num_peers }}
</a>
</td>
<td>
{{ App\Helpers\StringHelper::formatBytes($client->size) }}
</td>
@if (\config('announce.connectable_check') == true)
@php
$connectable = false;