作者 邓超

优化同步

... ... @@ -42,7 +42,7 @@ class Folder extends Base {
'`id`,`folder`,`pid`,`exsts`,`unseen`,`email_id`'
)
);
$es = es();
$data = [];
foreach ($emails as $eid=>$email){
if (empty($data[$email])){
... ... @@ -53,15 +53,22 @@ class Folder extends Base {
if($folder['email_id'] == $eid){
unset($folder['email_id']);
if(app()->request('shishi')){
$query = [
'query'=>[
'bool'=>[
'must'=>[
['term'=>['folder_id'=>$folder['id']]],
['term'=>['deleted'=>0]],
]
]
]
];
// 总数
$folder['exsts'] = db()->count(listsSql::listCount(
dbWhere(['folder_id'=> $folder['id'], 'deleted' => 0])
));
$folder['exsts'] = $es->count($query);
if($folder['folder']=='收件箱'){
$query['query']['bool']['must'][] = ['term'=>['seen'=>0]];
// 未读
$folder['unseen'] = db()->count(listsSql::listCount(
dbWhere(['folder_id'=> $folder['id'], 'seen' => 0, 'deleted' => 0])
));
$folder['unseen'] = $es->count($query);
}else{
$folder['unseen'] = 0;
}
... ...