* product: refactor getStoryCasesCount function.

This commit is contained in:
chentao
2023-05-12 16:28:07 +08:00
parent e918c876da
commit e37a49faba
2 changed files with 3 additions and 5 deletions
+1 -1
View File
@@ -1517,7 +1517,7 @@ class productModel extends model
}
}
$casesCount = $this->productTao->getStoriesInCasesCount($storyIdList);
$casesCount = $this->productTao->getStoryCasesCount($storyIdList);
$rate = count($stories) == 0 || $rateCount == 0 ? 0 : round($casesCount / $rateCount, 2);
$storyCommon = $this->lang->SRCommon;
+2 -4
View File
@@ -637,13 +637,11 @@ class productTao extends productModel
* @access protected
* @return int
*/
protected function getStoriesInCasesCount(array $storyIdList): int
protected function getStoryCasesCount(array $storyIdList): int
{
if(empty($storyIdList)) return 0;
$cases = $this->dao->select('story')->from(TABLE_CASE)->where('story')->in($storyIdList)->andWhere('deleted')->eq(0)->fetchAll('story');
return count($cases);
return $this->dao->select('COUNT(story) AS count')->from(TABLE_CASE)->where('story')->in($storyIdList)->andWhere('deleted')->eq('0')->fetch('count');
}
/**