Skip to content

Commit

Permalink
improve GenerateTemporaryInvite log
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Feb 26, 2024
1 parent b2f261b commit 240124a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions app/Jobs/GenerateTemporaryInvite.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ public function retryUntil()
*/
public function handle()
{
$beginTimestamp = microtime(true);
$toolRep = new ToolRepository();
$idStr = NexusDB::cache_get($this->idRedisKey);
$logPrefix = "idRedisKey: " . $this->idRedisKey;
if (empty($idStr)) {
do_log("no idStr of idRedisKey: {$this->idRedisKey}...");
do_log("$logPrefix, no idStr...");
return;
}
$idArr = explode(",", $idStr);
do_log(sprintf("going to handle %d uid...", count($idArr)));
$count = count($idArr);
$logPrefix .= ", count: $count";
do_log("$logPrefix, going to handle...");
$now = Carbon::now();
$expiredAt = Carbon::now()->addDays($this->days);
foreach ($idArr as $uid) {
Expand All @@ -84,12 +88,13 @@ public function handle()
if (!empty($data)) {
Invite::query()->insert($data);
}
do_log("success add $this->count temporary invite ($this->days days) to $uid");
do_log("$logPrefix, success add $this->count temporary invite ($this->days days) to $uid");
} catch (\Exception $exception) {
do_log("fail add $this->count temporary invite ($this->days days) to $uid: " . $exception->getMessage(), 'error');
do_log("$logPrefix, fail add $this->count temporary invite ($this->days days) to $uid: " . $exception->getMessage(), 'error');
}
}

NexusDB::cache_del($this->idRedisKey);
do_log("$logPrefix, handle done, cost time: " . (microtime(true) - $beginTimestamp) . " seconds.");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion include/constants.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.9');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-02-23');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-02-27');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
Expand Down

0 comments on commit 240124a

Please sign in to comment.