debug
This commit is contained in:
@@ -10,6 +10,8 @@ use GuzzleHttp\Client;
|
||||
use microserver\QueueManage;
|
||||
use QL\QueryList;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use think\facade\Cache;
|
||||
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
@@ -248,4 +250,19 @@ abstract class BasePage
|
||||
{
|
||||
return $this->Site;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $key
|
||||
* @param integer $expire
|
||||
* @return void
|
||||
*/
|
||||
public function redisDailyInc(string $key, int $expire = 604800) {
|
||||
$cache = Cache::store('redis');
|
||||
if (!$cache->has($key)) {
|
||||
$cache->set($key, 0, $expire);
|
||||
}
|
||||
$cache->inc($key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,8 @@ class ChapterPage extends BasePage
|
||||
empty($arrPageChapter['c_page_data']) ||
|
||||
count($arrPageChapter['c_page_data']) < 5
|
||||
) {
|
||||
$incKey = config('task.app_name').'_empty_saveChapter:' . date('Y-m-d');
|
||||
$this->redisDailyInc($incKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -145,6 +147,9 @@ class ChapterPage extends BasePage
|
||||
['$set' => $arrUpdate],
|
||||
);
|
||||
$this->strCContentPath = $arrExistsChapter['c_content_path'];
|
||||
|
||||
$incKey = config('task.app_name').'_update_saveChapter:' . date('Y-m-d');
|
||||
$this->redisDailyInc($incKey);
|
||||
} else {
|
||||
|
||||
$arrInsertNovel = $arrChapter;
|
||||
@@ -154,10 +159,18 @@ class ChapterPage extends BasePage
|
||||
|
||||
try {
|
||||
$this->getChapterModel()->insert($arrInsertNovel);
|
||||
|
||||
$incKey = config('task.app_name').'_success_saveChapter:' . date('Y-m-d');
|
||||
$this->redisDailyInc($incKey);
|
||||
|
||||
$this->updateNovelHaveChapter($intNId);
|
||||
$this->strCContentPath = $arrInsertNovel['c_content_path'];
|
||||
} catch (\Exception $e) {
|
||||
if ($e->getCode() === 11000) {
|
||||
|
||||
$incKey = config('task.app_name').'_11000_saveChapter:' . date('Y-m-d');
|
||||
$this->redisDailyInc($incKey);
|
||||
|
||||
return $this->saveChapter($intNId);
|
||||
} else {
|
||||
throw $e;
|
||||
|
||||
@@ -211,11 +211,12 @@ class Site
|
||||
$arrSuccessfulResults[$intKey] = $arrResult;
|
||||
|
||||
$incKey = config('task.app_name').'_success_getNovelPageInfo:' . date('Y-m-d'); // 例如:success_counter:2025-06-15
|
||||
Cache::store('redis')->inc($incKey);
|
||||
|
||||
$this->redisDailyInc($incKey);
|
||||
// Cache::store('redis')->inc($incKey);
|
||||
} elseif ($arrResult['state'] == 'rejected') {
|
||||
$incKey = config('task.app_name').'_errer_getNovelPageInfo:' . date('Y-m-d'); // 例如:success_counter:2025-06-15
|
||||
Cache::store('redis')->inc($incKey);
|
||||
$this->redisDailyInc($incKey);
|
||||
// Cache::store('redis')->inc($incKey);
|
||||
|
||||
if(config('log.task_debug_log_open_status')){
|
||||
// 记录失败原因
|
||||
@@ -276,12 +277,14 @@ class Site
|
||||
|
||||
$arrSuccessfulResults[$intKey] = $arrResult;
|
||||
|
||||
$incKey = config('task.app_name').'_success_getChapterPageList:' . date('Y-m-d'); // 例如:success_counter:2025-06-15
|
||||
Cache::store('redis')->inc($incKey);
|
||||
$incKey = config('task.app_name').'_success_getChapterPageList:' . date('Y-m-d');
|
||||
$this->redisDailyInc($incKey);
|
||||
// Cache::store('redis')->inc($incKey);
|
||||
|
||||
} elseif ($arrResult['state'] == 'rejected') {
|
||||
$incKey = config('task.app_name').'_errer_getChapterPageList:' . date('Y-m-d'); // 例如:success_counter:2025-06-15
|
||||
Cache::store('redis')->inc($incKey);
|
||||
$incKey = config('task.app_name').'_errer_getChapterPageList:' . date('Y-m-d');
|
||||
$this->redisDailyInc($incKey);
|
||||
// Cache::store('redis')->inc($incKey);
|
||||
if(config('log.task_debug_log_open_status')){
|
||||
// 记录失败原因
|
||||
$reason = $arrResult['reason'] instanceof \Exception ? $arrResult['reason']->getMessage() : 'Unknown error';
|
||||
@@ -340,12 +343,14 @@ class Site
|
||||
$arrSuccessfulResults[$intKey] = $arrResult;
|
||||
|
||||
$incKey = config('task.app_name').'_success_getLatestListPageList:' . date('Y-m-d');
|
||||
Cache::store('redis')->inc($incKey);
|
||||
$this->redisDailyInc($incKey);
|
||||
// Cache::store('redis')->inc($incKey);
|
||||
|
||||
} elseif ($arrResult['state'] == 'rejected') {
|
||||
|
||||
$incKey = config('task.app_name').'_errer_getLatestListPageList:' . date('Y-m-d');
|
||||
Cache::store('redis')->inc($incKey);
|
||||
$this->redisDailyInc($incKey);
|
||||
// Cache::store('redis')->inc($incKey);
|
||||
if(config('log.task_debug_log_open_status')){
|
||||
// 记录失败原因
|
||||
$reason = $arrResult['reason'] instanceof \Exception ? $arrResult['reason']->getMessage() : 'Unknown error';
|
||||
@@ -402,11 +407,13 @@ class Site
|
||||
$arrSuccessfulResults[$intKey] = $arrResult;
|
||||
|
||||
$incKey = config('task.app_name').'_success_downRemoteImgToLocal:' . date('Y-m-d');
|
||||
Cache::store('redis')->inc($incKey);
|
||||
$this->redisDailyInc($incKey);
|
||||
// Cache::store('redis')->inc($incKey);
|
||||
|
||||
} elseif ($arrResult['state'] == 'rejected') {
|
||||
$incKey = config('task.app_name').'_errer_downRemoteImgToLocal:' . date('Y-m-d');
|
||||
Cache::store('redis')->inc($incKey);
|
||||
$this->redisDailyInc($incKey);
|
||||
// Cache::store('redis')->inc($incKey);
|
||||
|
||||
if(config('log.task_debug_log_open_status')){
|
||||
// 记录失败原因
|
||||
@@ -459,4 +466,19 @@ class Site
|
||||
{
|
||||
return new LatestListPage($Site, $strUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $key
|
||||
* @param integer $expire
|
||||
* @return void
|
||||
*/
|
||||
public function redisDailyInc(string $key, int $expire = 604800) {
|
||||
$cache = Cache::store('redis');
|
||||
if (!$cache->has($key)) {
|
||||
$cache->set($key, 0, $expire);
|
||||
}
|
||||
$cache->inc($key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user