mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 04:20:49 +08:00
[api] user torrents stat
This commit is contained in:
@@ -177,13 +177,13 @@ class UserController extends Controller
|
||||
$rows = [
|
||||
[
|
||||
['icon' => 'icon-user', 'label' => '种子评论', 'name' => 'comments_count'],
|
||||
['icon' => 'icon-user', 'label' => '论坛坛子', 'name' => 'posts_count'],
|
||||
['icon' => 'icon-user', 'label' => '论坛帖子', 'name' => 'posts_count'],
|
||||
],[
|
||||
['icon' => 'icon-user', 'label' => '发布种子', 'name' => 'comments_count'],
|
||||
['icon' => 'icon-user', 'label' => '当前做种', 'name' => 'posts_count'],
|
||||
['icon' => 'icon-user', 'label' => '当前下载', 'name' => 'posts_count'],
|
||||
['icon' => 'icon-user', 'label' => '完成种子', 'name' => 'posts_count'],
|
||||
['icon' => 'icon-user', 'label' => '未完成种子', 'name' => 'posts_count'],
|
||||
['icon' => 'icon-user', 'label' => '发布种子', 'name' => 'torrents_count'],
|
||||
['icon' => 'icon-user', 'label' => '当前做种', 'name' => 'seeding_torrents_count'],
|
||||
['icon' => 'icon-user', 'label' => '当前下载', 'name' => 'leeching_torrents_count'],
|
||||
['icon' => 'icon-user', 'label' => '完成种子', 'name' => 'completed_torrents_count'],
|
||||
['icon' => 'icon-user', 'label' => '未完成种子', 'name' => 'incomplete_torrents_count'],
|
||||
]
|
||||
];
|
||||
$resource->additional([
|
||||
@@ -196,7 +196,11 @@ class UserController extends Controller
|
||||
|
||||
private function getUserProfile($id)
|
||||
{
|
||||
$user = User::query()->withCount(['comments', 'posts'])->findOrFail($id);
|
||||
$user = User::query()->withCount([
|
||||
'comments', 'posts', 'torrents', 'seeding_torrents', 'leeching_torrents',
|
||||
'completed_torrents' => function ($query) use ($id) {$query->where('snatched.userid', '!=', $id);},
|
||||
'incomplete_torrents' => function ($query) use ($id) {$query->where('snatched.userid', '!=', $id);},
|
||||
])->findOrFail($id);
|
||||
$resource = new UserResource($user);
|
||||
return $resource;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class UserResource extends JsonResource
|
||||
'uploaded_text' => mksize($this->uploaded),
|
||||
'downloaded' => $this->downloaded,
|
||||
'downloaded_text' => mksize($this->downloaded),
|
||||
'bonus' => $this->seedbonus,
|
||||
'seed_bonus' => $this->seedbonus,
|
||||
'seed_points' => $this->seed_points,
|
||||
'seedtime' => $this->seedtime,
|
||||
'seedtime_text' => mkprettytime($this->seedtime),
|
||||
@@ -43,10 +43,14 @@ class UserResource extends JsonResource
|
||||
$out['seed_time'] = mkprettytime($this->seedtime);
|
||||
$out['leech_time'] = mkprettytime($this->leechtime);
|
||||
$out['share_ratio'] = get_share_ratio($this->uploaded, $this->downloaded);
|
||||
$out['seed_bonus'] = $this->seedbonus;
|
||||
$out['invites'] = $this->invites;
|
||||
$out['comments_count'] = $this->comments_count;
|
||||
$out['posts_count'] = $this->posts_count;
|
||||
$out['torrents_count'] = $this->torrents_count;
|
||||
$out['seeding_torrents_count'] = $this->seeding_torrents_count;
|
||||
$out['leeching_torrents_count'] = $this->leeching_torrents_count;
|
||||
$out['completed_torrents_count'] = $this->completed_torrents_count;
|
||||
$out['incomplete_torrents_count'] = $this->incomplete_torrents_count;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user