Skip to content

Commit

Permalink
Merge pull request #4169 from Roardom/profile-client-seedsize
Browse files Browse the repository at this point in the history
(Add) Client torrent size sum to profile page
  • Loading branch information
HDVinnie authored Nov 21, 2024
2 parents cabf501 + 69b7f1f commit a93c9f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Http/Controllers/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ public function show(Request $request, User $user): \Illuminate\Contracts\View\F
// '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(),
Expand Down
4 changes: 4 additions & 0 deletions resources/views/user/profile/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class="user-search__avatar"
<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
Expand Down Expand Up @@ -300,6 +301,9 @@ class="user-search__avatar"
{{ $client->num_peers }}
</a>
</td>
<td>
{{ App\Helpers\StringHelper::formatBytes($client->size) }}
</td>
@if (\config('announce.connectable_check') == true)
@php
$connectable = false;
Expand Down

0 comments on commit a93c9f1

Please sign in to comment.