* [refac story #74534] Adjust code for actionModel hasPreOrNext method.

This commit is contained in:
wangyidong
2025-05-29 11:23:28 +08:00
parent 4dbb9eb12c
commit b367f11c3b
4 changed files with 14 additions and 14 deletions
+2
View File
@@ -2,6 +2,7 @@ window.showMore = function(e)
{
let $this = $(e.target);
if($this.attr('id') != 'showMoreDynamic') $this = $this.closest('#showMoreDynamic');
$this.find('i').removeClass('icon-chevron-down').addClass('spin icon-refresh');
let $appendTo = $this.closest('li').prev().find('ul');
let lastActionID = $this.data('lastid');
@@ -11,6 +12,7 @@ window.showMore = function(e)
let hasMore = $appendTo.children('#hasMore').html() == '1';
$this.attr('data-lastid', $appendTo.children('#lastid').html());
$this.find('i').addClass('icon-chevron-down').removeClass('spin icon-refresh');
if(!hasMore) $this.closest('li').remove();
$appendTo.children('style').remove();
+2 -1
View File
@@ -414,9 +414,10 @@ class action extends control
public function ajaxGetMoreActions(int $lastActionID)
{
$actions = $this->action->getMoreActions($lastActionID);
$lastAction = end($actions);
$this->view->actions = $actions;
$this->view->hasMore = $this->action->hasMoreAction(end($actions));
$this->view->hasMore = $lastAction ? $this->action->hasMoreAction($lastAction) : false;
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->display();
}
+9 -11
View File
@@ -1747,17 +1747,14 @@ class actionModel extends model
if(empty($date)) return false;
$condition = $this->session->actionQueryCondition;
/* 移除搜索中的时间筛选条件。 */
/* Remove time filter from search. */
$condition = preg_replace("/AND +`?date`? +(<|>|<=|>=) +'\d{4}\-\d{2}\-\d{2}'/", '', $condition);
$count = $this->dao->select('COUNT(1) AS count')
->from(TABLE_ACTION)->alias('action')
$actions = $this->dao->select('action.id')->from(TABLE_ACTION)->alias('action')
->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action')
->where($condition)
->andWhere('date' . ($direction == 'next' ? '<' : '>') . "'{$date}'")
->fetch('count');
->limit(1)
->fetchAll();
return $count > 0;
return count($actions) > 0;
}
/**
@@ -2471,14 +2468,15 @@ class actionModel extends model
*/
public function hasMoreAction(object $lastAction): bool
{
$hasCount = $this->dao->select('count(*) AS count')->from(TABLE_ACTION)->alias('action')
$actions = $this->dao->select('action.id')->from(TABLE_ACTION)->alias('action')
->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action')
->where($this->session->actionQueryCondition)
->andWhere("`date`")->like(substr($lastAction->originalDate, 0, 10) . " %")
->andWhere('action.id < ' . $lastAction->id)
->orderBy($this->session->actionOrderBy)
->fetch('count');
return $hasCount > 0;
->limit(1)
->fetchAll();
return count($actions) > 0;
}
/**
@@ -2490,7 +2488,7 @@ class actionModel extends model
* @access public
* @return array
*/
public function getMoreActions(int $lastActionID, int $limit = 100): array
public function getMoreActions(int $lastActionID, int $limit = 50): array
{
$lastAction = $this->dao->select('*')->from(TABLE_ACTION)->where('id')->eq($lastActionID)->fetch();
$actions = $this->dao->select('action.*')->from(TABLE_ACTION)->alias('action')
+1 -2
View File
@@ -176,8 +176,7 @@ class company extends control
/* 根据日期补充动态数据。*/
/* Supplement action by date.*/
$dateGroups = $this->action->buildDateGroup($actions, $direction, $orderBy);
if(empty($recTotal)) $recTotal = !(empty($date) && $browseType == 'all') ? array_sum(array_map('count', $dateGroups)) : $this->action->getDynamicCount();
$recTotal = $this->action->getDynamicCount();
/* Assign.*/
$this->view->title = $this->lang->company->common . $this->lang->hyphen . $this->lang->company->dynamic;