improve job log

This commit is contained in:
xiaomlove
2023-02-21 01:04:28 +08:00
parent 64defea3e3
commit eb04b9d2d0
7 changed files with 45 additions and 23 deletions
+13 -2
View File
@@ -52,7 +52,7 @@ class CalculateUserSeedBonus implements ShouldQueue
public function handle()
{
$beginTimestamp = time();
$logPrefix = sprintf("[CLEANUP_CLI_CALCULATE_SEED_BONUS], commonRequestId: %s, beginUid: %s, endUid: %s", $this->requestId, $this->beginUid, $this->endUid);
$logPrefix = sprintf("[CLEANUP_CLI_CALCULATE_SEED_BONUS_HANDLE_JOB], commonRequestId: %s, beginUid: %s, endUid: %s", $this->requestId, $this->beginUid, $this->endUid);
$sql = sprintf("select userid from peers where userid > %s and userid <= %s and seeder = 'yes' group by userid", $this->beginUid, $this->endUid);
$results = NexusDB::select($sql);
$count = count($results);
@@ -73,7 +73,7 @@ class CalculateUserSeedBonus implements ShouldQueue
$uid = $userInfo['id'];
$isDonor = is_donor($userInfo);
$seedBonusResult = calculate_seed_bonus($uid);
$bonusLog = "[CLEANUP_CALCULATE_SEED_BONUS], user: $uid, seedBonusResult: " . nexus_json_encode($seedBonusResult);
$bonusLog = "[CLEANUP_CLI_CALCULATE_SEED_BONUS_HANDLE_USER], user: $uid, seedBonusResult: " . nexus_json_encode($seedBonusResult);
$all_bonus = $seedBonusResult['seed_bonus'];
$bonusLog .= ", all_bonus: $all_bonus";
if ($isDonor) {
@@ -107,4 +107,15 @@ class CalculateUserSeedBonus implements ShouldQueue
$costTime = time() - $beginTimestamp;
do_log("$logPrefix, [DONE], cost time: $costTime seconds");
}
/**
* Handle a job failure.
*
* @param \Throwable $exception
* @return void
*/
public function failed(\Throwable $exception)
{
do_log("failed: " . $exception->getMessage() . $exception->getTraceAsString(), 'error');
}
}
+13 -2
View File
@@ -52,7 +52,7 @@ class UpdateTorrentSeedersEtc implements ShouldQueue
public function handle()
{
$beginTimestamp = time();
$logPrefix = sprintf("[CLEANUP_CLI_UPDATE_TORRENT_SEEDERS_ETC], commonRequestId: %s, beginTorrentId: %s, endTorrentId: %s", $this->requestId, $this->beginTorrentId, $this->endTorrentId);
$logPrefix = sprintf("[CLEANUP_CLI_UPDATE_TORRENT_SEEDERS_ETC_HANDLE_JOB], commonRequestId: %s, beginTorrentId: %s, endTorrentId: %s", $this->requestId, $this->beginTorrentId, $this->endTorrentId);
// $sql = sprintf("update torrents set seeders = (select count(*) from peers where torrent = torrents.id and seeder = 'yes'), leechers = (select count(*) from peers where torrent = torrents.id and seeder = 'no'), comments = (select count(*) from comments where torrent = torrents.id) where id > %s and id <= %s",
// $this->beginTorrentId, $this->endTorrentId
// );
@@ -88,7 +88,7 @@ class UpdateTorrentSeedersEtc implements ShouldQueue
}
}
NexusDB::table('torrents')->where('id', $torrent->id)->update($update);
do_log("$logPrefix, [SUCCESS]: $torrent->id => " . json_encode($update));
do_log("[CLEANUP_CLI_UPDATE_TORRENT_SEEDERS_ETC_HANDLE_TORRENT], [SUCCESS]: $torrent->id => " . json_encode($update));
}
$costTime = time() - $beginTimestamp;
do_log(sprintf(
@@ -96,4 +96,15 @@ class UpdateTorrentSeedersEtc implements ShouldQueue
count($torrents), $costTime
));
}
/**
* Handle a job failure.
*
* @param \Throwable $exception
* @return void
*/
public function failed(\Throwable $exception)
{
do_log("failed: " . $exception->getMessage() . $exception->getTraceAsString(), 'error');
}
}