作者 邓超

优化同步

@@ -42,7 +42,7 @@ class Folder extends Base { @@ -42,7 +42,7 @@ class Folder extends Base {
42 '`id`,`folder`,`pid`,`exsts`,`unseen`,`email_id`' 42 '`id`,`folder`,`pid`,`exsts`,`unseen`,`email_id`'
43 ) 43 )
44 ); 44 );
45 - 45 + $es = es();
46 $data = []; 46 $data = [];
47 foreach ($emails as $eid=>$email){ 47 foreach ($emails as $eid=>$email){
48 if (empty($data[$email])){ 48 if (empty($data[$email])){
@@ -53,15 +53,22 @@ class Folder extends Base { @@ -53,15 +53,22 @@ class Folder extends Base {
53 if($folder['email_id'] == $eid){ 53 if($folder['email_id'] == $eid){
54 unset($folder['email_id']); 54 unset($folder['email_id']);
55 if(app()->request('shishi')){ 55 if(app()->request('shishi')){
  56 + $query = [
  57 + 'query'=>[
  58 + 'bool'=>[
  59 + 'must'=>[
  60 + ['term'=>['folder_id'=>$folder['id']]],
  61 + ['term'=>['deleted'=>0]],
  62 + ]
  63 + ]
  64 + ]
  65 + ];
56 // 总数 66 // 总数
57 - $folder['exsts'] = db()->count(listsSql::listCount(  
58 - dbWhere(['folder_id'=> $folder['id'], 'deleted' => 0])  
59 - )); 67 + $folder['exsts'] = $es->count($query);
60 if($folder['folder']=='收件箱'){ 68 if($folder['folder']=='收件箱'){
  69 + $query['query']['bool']['must'][] = ['term'=>['seen'=>0]];
61 // 未读 70 // 未读
62 - $folder['unseen'] = db()->count(listsSql::listCount(  
63 - dbWhere(['folder_id'=> $folder['id'], 'seen' => 0, 'deleted' => 0])  
64 - )); 71 + $folder['unseen'] = $es->count($query);
65 }else{ 72 }else{
66 $folder['unseen'] = 0; 73 $folder['unseen'] = 0;
67 } 74 }