Merge branch release/21.7.3 of zentao/zentaopms (#10180)
This commit is contained in:
+6
-16
@@ -20,8 +20,6 @@ class actionModel extends model
|
||||
const BE_HIDDEN = 2; // The deleted object has been hidden.
|
||||
const MAXCOUNT = 1000;
|
||||
|
||||
public $productAlias = 't2';
|
||||
|
||||
/**
|
||||
* 创建一个操作记录。
|
||||
* Create a action.
|
||||
@@ -1082,9 +1080,6 @@ class actionModel extends model
|
||||
*/
|
||||
public function getDynamicByProduct(int $productID, string $account = 'all', string $period = 'all', string $orderBy = 'date_desc', int $limit = 50, string $date = '', string $direction = 'next'): array
|
||||
{
|
||||
$count = $this->dao->select('COUNT(1) AS count')->from(TABLE_ACTIONPRODUCT)->where('product')->eq($productID)->fetch('count');
|
||||
if($count > 10000) $this->productAlias = 't2 FORCE INDEX (action_product)';
|
||||
|
||||
return $this->getDynamic($account, $period, $orderBy, $limit, (int)$productID, 'all', 'all', $date, $direction);
|
||||
}
|
||||
|
||||
@@ -1214,12 +1209,7 @@ class actionModel extends model
|
||||
/* If the query condition include all executions, no limit execution. */
|
||||
if(strpos($actionQuery, $allExecutions) !== false) $actionQuery = str_replace($allExecutions, '1 = 1', $actionQuery);
|
||||
|
||||
if($productID)
|
||||
{
|
||||
$actionQuery = str_replace(" `product` = '{$productID}'", " t2.`product` = '{$productID}'", $actionQuery);
|
||||
$count = $this->dao->select('count(1) as count')->from(TABLE_ACTIONPRODUCT)->where('product')->eq($productID)->fetch('count');
|
||||
if($count > 10000) $this->productAlias = 't2 FORCE INDEX (action_product)';
|
||||
}
|
||||
if($productID) $actionQuery = str_replace(" `product` = '{$productID}'", " t2.`product` = '{$productID}'", $actionQuery);
|
||||
if($date) $actionQuery = "({$actionQuery}) AND " . ('date' . ($direction == 'next' ? '<' : '>') . "'{$date}'");
|
||||
|
||||
/* 如果当前版本为lite,则过滤掉产品相关的动态。 */
|
||||
@@ -1257,7 +1247,7 @@ class actionModel extends model
|
||||
if($noMultipleExecutions) $condition = "({$condition}) AND (`objectType` != 'execution' OR (`objectType` = 'execution' AND `objectID`" . (count($noMultipleExecutions) == 1 ? ' != ' . reset($noMultipleExecutions) : ' NOT ' . helper::dbIN($noMultipleExecutions)) . "))";
|
||||
|
||||
return $this->dao->select('action.*')->from(TABLE_ACTION)->alias('action')
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias($this->productAlias)->on('action.id=t2.action')->fi()
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action')->fi()
|
||||
->where('objectType')->notIN($this->config->action->ignoreObjectType4Dynamic)
|
||||
->andWhere('action.action')->notIN($this->config->action->ignoreActions4Dynamic)
|
||||
->andWhere("({$sql})")
|
||||
@@ -1956,7 +1946,7 @@ class actionModel extends model
|
||||
$hasProduct = preg_match('/t2\.(`?)product/', $condition);
|
||||
$condition = preg_replace("/AND +`?date`? +(<|>|<=|>=) +'\d{4}\-\d{2}\-\d{2}'/", '', $condition);
|
||||
$actions = $this->dao->select('action.id')->from(TABLE_ACTION)->alias('action')
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias($this->productAlias)->on('action.id=t2.action')->fi()
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action')->fi()
|
||||
->where($condition)
|
||||
->andWhere('`date`' . ($direction == 'next' ? '<' : '>') . "'{$date}'")
|
||||
->beginIF($direction == 'next' && $beginAndEnd['begin'] != EPOCH_DATE)->andWhere('date')->ge($beginAndEnd['begin'])->fi()
|
||||
@@ -2572,7 +2562,7 @@ class actionModel extends model
|
||||
$condition = preg_replace("/AND +`?date`? +(<|>|<=|>=) +'\d{4}\-\d{2}\-\d{2}'/", '', $condition);
|
||||
|
||||
$actions = $this->dao->select('action.id')->from($table)->alias('action')
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias($this->productAlias)->on('action.id=t2.action')->fi()
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action')->fi()
|
||||
->where($condition)
|
||||
->beginIF($beginAndEnd['begin'] != EPOCH_DATE)->andWhere('date')->ge($beginAndEnd['begin'])->fi()
|
||||
->beginIF($beginAndEnd['end'] != FUTURE_DATE)->andWhere('date')->le($beginAndEnd['end'])->fi()
|
||||
@@ -2630,7 +2620,7 @@ class actionModel extends model
|
||||
$lastDate = substr($lastAction->originalDate, 0, 10);
|
||||
$condition = preg_replace("/AND +`?date`? +(<|>|<=|>=) +'\d{4}\-\d{2}\-\d{2}'/", '', $condition);
|
||||
$actions = $this->dao->select('action.id')->from(TABLE_ACTION)->alias('action')
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias($this->productAlias)->on('action.id=t2.action')->fi()
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action')->fi()
|
||||
->where($condition)
|
||||
->andWhere("`date`")->ge($lastDate)
|
||||
->andWhere("`date`")->lt($lastDate . ' 23:59:59')
|
||||
@@ -2659,7 +2649,7 @@ class actionModel extends model
|
||||
$lastAction = $this->dao->select('*')->from(TABLE_ACTION)->where('id')->eq($lastActionID)->fetch();
|
||||
$lastDate = substr($lastAction->date, 0, 10);
|
||||
$actions = $this->dao->select('action.*')->from(TABLE_ACTION)->alias('action')
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias($this->productAlias)->on('action.id=t2.action')->fi()
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action')->fi()
|
||||
->where($condition)
|
||||
->andWhere("`date`")->ge($lastDate)
|
||||
->andWhere("`date`")->lt($lastDate . ' 23:59:59')
|
||||
|
||||
@@ -703,7 +703,7 @@ class actionTao extends actionModel
|
||||
if($productID === 'notzero') $hasProduct = true;
|
||||
|
||||
return $this->dao->select('action.*')->from($actionTable)->alias('action')
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias($this->productAlias)->on('action.id=t2.action')->fi()
|
||||
->beginIF($hasProduct)->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action')->fi()
|
||||
->where('objectType')->notIN($this->config->action->ignoreObjectType4Dynamic)
|
||||
->andWhere('action.action')->notIN($this->config->action->ignoreActions4Dynamic)
|
||||
->andWhere('vision')->eq($this->config->vision)
|
||||
|
||||
Reference in New Issue
Block a user