feature: video rank list add vc_clicks

This commit is contained in:
Default
2025-05-05 14:15:21 +08:00
parent 4400055b06
commit 017572b170
4 changed files with 22 additions and 13 deletions

View File

@@ -447,6 +447,7 @@ class VideoModel extends MongoModel
'limit' => $intCount * 3,
'projection' => [
'v_id' => 1,
'vc_clicks' => 1,
],
];
@@ -455,11 +456,15 @@ class VideoModel extends MongoModel
$Cursor = $VideoClicksModel->getCol()->find($arrFilter, $arrOptions);
$arrVId = [];
$arrVideoClicks = [];
foreach ($Cursor as $Doc) {
$arrVId[] = $Doc['v_id'];
$arrVideoClicks[$Doc['v_id']] = $Doc['vc_clicks'];
}
$arrFilter = ['v_id' => ['$in' => $arrVId]];
$arrFilter = ['v_id' => ['$in' => $arrVId]];
$arrOptions = self::$arrOptions;
unset($arrOptions['typeMap']);
@@ -473,10 +478,13 @@ class VideoModel extends MongoModel
shuffle($arrResult);
$arrResult = array_slice($arrResult, 0, $intCount);
foreach ($arrResult as &$arrVideo) {
$arrVideo['vc_clicks'] = $arrVideoClicks[$arrVideo['v_id']];
}
$this->setCacheByKey($strKey, $arrResult, $intLifeTime);
return $arrResult;
return $arrResult;
} catch (\Exception $e) {
return [];
}