作者 lyh

变更数据

@@ -135,16 +135,23 @@ class GeoQuestionResLogic extends BaseLogic @@ -135,16 +135,23 @@ class GeoQuestionResLogic extends BaseLogic
135 ]; 135 ];
136 }else{ 136 }else{
137 $keywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0]]); 137 $keywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0]]);
  138 + $keywordArrs = [];
  139 + $urlArrs = [];
138 foreach ($list as $item){ 140 foreach ($list as $item){
  141 + $keywordArrs = array_merge($keywordArrs,$item['keywords'] ?? []);
  142 + $urlArrs = array_merge($urlArrs,$item['url'] ??[]);
139 $questionTotalCount += count($item['question'] ?? []); 143 $questionTotalCount += count($item['question'] ?? []);
140 - $keywordsTotalCount += count($item['keywords'] ?? []);  
141 - $urlTotalCount += count($item['url'] ?? []);  
142 foreach ($item['keywords'] as $keyWordItem){ 144 foreach ($item['keywords'] as $keyWordItem){
143 if (!array_key_exists($keyWordItem, $keywordArr)) { 145 if (!array_key_exists($keyWordItem, $keywordArr)) {
144 $keywordArr[$keyWordItem] = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'keywords'=>['like','%"'.$keyWordItem.'"%']]); 146 $keywordArr[$keyWordItem] = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'keywords'=>['like','%"'.$keyWordItem.'"%']]);
145 } 147 }
146 } 148 }
147 } 149 }
  150 + // 去重
  151 + $keywordArrs = array_unique($keywordArrs);
  152 + $keywordsTotalCount = count($keywordArrs);
  153 + $urlArrs = array_unique($urlArrs);
  154 + $urlTotalCount = count($urlArrs);
148 $data = [ 155 $data = [
149 'question_count'=>$questionTotalCount, 156 'question_count'=>$questionTotalCount,
150 'keywords_count'=>$keywordsTotalCount, 157 'keywords_count'=>$keywordsTotalCount,