mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
API add more log
This commit is contained in:
@@ -28,8 +28,11 @@ class TorrentController extends Controller
|
||||
|
||||
public function index(Request $request, string $section = null)
|
||||
{
|
||||
do_log("controller torrent index entry");
|
||||
$result = $this->repository->getList($request, Auth::user(), $section);
|
||||
do_log("controller torrent index getList");
|
||||
$resource = TorrentResource::collection($result);
|
||||
do_log("controller torrent index prepare resource");
|
||||
return $this->success($resource);
|
||||
}
|
||||
|
||||
@@ -55,11 +58,13 @@ class TorrentController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
do_log("controller torrent show entry");
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
$user = Auth::user();
|
||||
$torrent = $this->repository->getDetail($id, $user);
|
||||
do_log("controller torrent show getDetail");
|
||||
$resource = new TorrentResource($torrent);
|
||||
$additional = [];
|
||||
if ($this->hasExtraField('bonus_reward_values')) {
|
||||
@@ -68,6 +73,7 @@ class TorrentController extends Controller
|
||||
$extraSettingsNames = ['torrent.claim_torrent_user_counts_up_limit'];
|
||||
$this->appendExtraSettings($additional, $extraSettingsNames);
|
||||
$resource->additional($additional);
|
||||
do_log("controller torrent show prepare resource");
|
||||
return $this->success($resource);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,9 @@ class TorrentRepository extends BaseRepository
|
||||
if (!$apiQueryBuilder->hasSort() || !$apiQueryBuilder->hasSort('id')) {
|
||||
$query->orderBy("id", "DESC");
|
||||
}
|
||||
do_log("before query torrent list");
|
||||
$torrents = $query->paginate($this->getPerPageFromRequest($request));
|
||||
do_log("after query torrent list");
|
||||
return $this->appendIncludeFields($apiQueryBuilder, $user, $torrents);
|
||||
}
|
||||
|
||||
@@ -175,7 +177,9 @@ class TorrentRepository extends BaseRepository
|
||||
->allowIncludeCounts($allowIncludeCounts)
|
||||
->allowIncludeFields($allowIncludeFields)
|
||||
;
|
||||
do_log("before query torrent detail");
|
||||
$torrent = $apiQueryBuilder->build()->findOrFail($id);
|
||||
do_log("before query torrent detail");
|
||||
$torrentList = $this->appendIncludeFields($apiQueryBuilder, $user, [$torrent]);
|
||||
return $torrentList[0];
|
||||
}
|
||||
@@ -199,6 +203,7 @@ class TorrentRepository extends BaseRepository
|
||||
if ($hasFieldHasRewarded = $apiQueryBuilder->hasIncludeField('has_rewarded')) {
|
||||
$rewardData = $user->reward_torrent_logs()->whereIn('torrentid', $torrentIdArr)->get()->keyBy('torrentid');
|
||||
}
|
||||
do_log("after prepare has data");
|
||||
|
||||
foreach ($torrentList as $torrent) {
|
||||
$id = $torrent->id;
|
||||
@@ -216,7 +221,9 @@ class TorrentRepository extends BaseRepository
|
||||
}
|
||||
|
||||
if ($apiQueryBuilder->hasIncludeField('description') && $apiQueryBuilder->hasInclude('extra')) {
|
||||
do_log("before format_description of torrent: {$torrent->id}");
|
||||
$descriptionArr = format_description($torrent->extra->descr ?? '');
|
||||
do_log("after format_description of torrent: {$torrent->id}");
|
||||
$torrent->description = $descriptionArr;
|
||||
$torrent->images = get_image_from_description($descriptionArr);
|
||||
}
|
||||
@@ -224,6 +231,7 @@ class TorrentRepository extends BaseRepository
|
||||
$torrent->download_url = $this->getDownloadUrl($id, $user);
|
||||
}
|
||||
}
|
||||
do_log("after fill has data");
|
||||
return $torrentList;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user