refactor: encapsed strings to sprintf

This commit is contained in:
HDVinnie
2020-02-17 13:52:20 -05:00
parent 61fa3f8900
commit 605c337204
61 changed files with 245 additions and 218 deletions
+3 -3
View File
@@ -123,7 +123,7 @@ class AnnounceController extends Controller
}
// Check Passkey Against Cache or Users Table
$user = Cache::get("user.{$passkey}") ?? User::where('passkey', '=', $passkey)->first();
$user = Cache::get(sprintf('user.%s', $passkey)) ?? User::where('passkey', '=', $passkey)->first();
// If Passkey Doesn't Exist Return Error to Client
if ($user === null) {
@@ -206,7 +206,7 @@ class AnnounceController extends Controller
}
// Check Info Hash Against Cache or Torrents Table
$torrent = Cache::get("torrent.{$info_hash}") ?? Torrent::select(['id', 'status', 'free', 'doubleup', 'times_completed', 'seeders', 'leechers'])->withAnyStatus()->where('info_hash', '=', $info_hash)->first();
$torrent = Cache::get(sprintf('torrent.%s', $info_hash)) ?? Torrent::select(['id', 'status', 'free', 'doubleup', 'times_completed', 'seeders', 'leechers'])->withAnyStatus()->where('info_hash', '=', $info_hash)->first();
// If Torrent Doesnt Exsist Return Error to Client
if ($torrent === null) {
@@ -236,7 +236,7 @@ class AnnounceController extends Controller
$peers = Peer::where('torrent_id', '=', $torrent->id)->take(50)->get()->toArray();
// Pull Count On Users Peers Per Torrent For Rate Limiting
$connections = Cache::remember("user_connections.{$torrent->id}", 1800, function () use ($torrent, $user) {
$connections = Cache::remember(sprintf('user_connections.%s', $torrent->id), 1800, function () use ($torrent, $user) {
return Peer::where('torrent_id', '=', $torrent->id)->where('user_id', '=', $user->id)->count();
});