* Optimize bug batchChangePlan function.
This commit is contained in:
@@ -108,7 +108,7 @@ $config->bug->form->resolve['duplicateBug'] = array('required' => false, 'type
|
||||
$config->bug->form->resolve['buildName'] = array('required' => false, 'type' => 'string', 'default' => '');
|
||||
$config->bug->form->resolve['createBuild'] = array('required' => false, 'type' => 'string', 'default' => 'off');
|
||||
$config->bug->form->resolve['buildExecution'] = array('required' => false, 'type' => 'int', 'default' => 0);
|
||||
$config->bug->form->confirm['comment'] = array('required' => false, 'type' => 'string', 'default' => '');
|
||||
$config->bug->form->resolve['comment'] = array('required' => false, 'type' => 'string', 'default' => '');
|
||||
|
||||
$config->bug->form->activate = array();
|
||||
$config->bug->form->activate['assignedTo'] = array('required' => false, 'type' => 'string', 'default' => '');
|
||||
|
||||
+11
-10
@@ -696,15 +696,13 @@ class bug extends control
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$bugs = $this->bugZen->buildBugsForBatchCreate($productID, $branch, $this->session->bugImagesFile);
|
||||
|
||||
/* Check bugs. */
|
||||
$bugs = $this->bugZen->checkBugsForBatchCreate($bugs, $productID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$message = '';
|
||||
$bugIDList = array();
|
||||
$uploadImages = $this->post->uploadImage;
|
||||
$bugImagesFiles = $this->session->bugImagesFile;
|
||||
$bugIDList = array();
|
||||
$message = '';
|
||||
foreach($bugs as $index => $bug)
|
||||
{
|
||||
$uploadImage = !empty($uploadImages[$index]) ? $uploadImages[$index] : '';
|
||||
@@ -735,10 +733,8 @@ class bug extends control
|
||||
$this->bugZen->assignBatchCreateVars($executionID, $product, $branch, $output, $this->session->bugImagesFile);
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->batchCreate;
|
||||
$this->view->users = $this->user->getPairs('devfirst|noclosed');
|
||||
$this->view->moduleID = $moduleID;
|
||||
$this->view->product = $product;
|
||||
$this->view->productID = $product->id;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -826,6 +822,7 @@ class bug extends control
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
}
|
||||
|
||||
$this->loadModel('score')->create('ajax', 'batchOther');
|
||||
return array('load' => $this->session->bugList, 'closeModal' => true);
|
||||
}
|
||||
@@ -851,6 +848,7 @@ class bug extends control
|
||||
|
||||
$this->bug->update($bug);
|
||||
}
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
$this->loadModel('score')->create('ajax', 'batchOther');
|
||||
}
|
||||
@@ -867,13 +865,14 @@ class bug extends control
|
||||
*/
|
||||
public function batchChangePlan(int $planID)
|
||||
{
|
||||
if($this->post->bugIDList)
|
||||
if(!empty($_POST) && isset($_POST['bugIdList']))
|
||||
{
|
||||
$bugIdList = array_unique($this->post->bugIDList);
|
||||
$this->bug->batchChangePlan($bugIdList, $planID);
|
||||
$bugIdList = array_unique($this->post->bugIdList);
|
||||
$this->bugZen->batchChangePlan($bugIdList, $planID);
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
$this->loadModel('score')->create('ajax', 'batchOther');
|
||||
}
|
||||
$this->loadModel('score')->create('ajax', 'batchOther');
|
||||
return array('load' => $this->session->bugList, 'closeModal' => true);
|
||||
}
|
||||
|
||||
@@ -898,6 +897,7 @@ class bug extends control
|
||||
{
|
||||
$bug->id = (int)$bugID;
|
||||
$bug->assignedTo = $assignedTo;
|
||||
|
||||
$this->bug->assign($bug);
|
||||
}
|
||||
|
||||
@@ -932,6 +932,7 @@ class bug extends control
|
||||
$bug->id = (int)$bugID;
|
||||
$bug->confirmed = 1;
|
||||
$bug->assignedTo = $this->app->user->account;
|
||||
|
||||
$this->bug->confirm($bug);
|
||||
$message = $this->executeHooks($bugID);
|
||||
}
|
||||
|
||||
+5
-49
@@ -365,11 +365,11 @@ class bugModel extends model
|
||||
$this->dao->update(TABLE_BUG)->data($bug, 'deleteFiles,comment')
|
||||
->autoCheck()
|
||||
->batchCheck($this->config->bug->edit->requiredFields, 'notempty')
|
||||
->checkIF($bug->resolvedBy, 'resolution', 'notempty')
|
||||
->checkIF($bug->closedBy, 'resolution', 'notempty')
|
||||
->checkIF($bug->notifyEmail,'notifyEmail', 'email')
|
||||
->checkIF($bug->resolution == 'duplicate', 'duplicateBug', 'notempty')
|
||||
->checkIF($bug->resolution == 'fixed', 'resolvedBuild','notempty')
|
||||
->checkIF(!empty($bug->resolvedBy), 'resolution', 'notempty')
|
||||
->checkIF(!empty($bug->closedBy), 'resolution', 'notempty')
|
||||
->checkIF(!empty($bug->notifyEmail),'notifyEmail', 'email')
|
||||
->checkIF(!empty($bug->resolution) && $bug->resolution == 'duplicate', 'duplicateBug', 'notempty')
|
||||
->checkIF(!empty($bug->resolution) && $bug->resolution == 'fixed', 'resolvedBuild','notempty')
|
||||
->checkFlow()
|
||||
->where('id')->eq($bug->id)
|
||||
->exec();
|
||||
@@ -727,50 +727,6 @@ class bugModel extends model
|
||||
return $allChanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改bug计划。
|
||||
* Batch change the plan of bug.
|
||||
*
|
||||
* @param array $bugIdList
|
||||
* @param int $planID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function batchChangePlan(array $bugIdList, int $planID): void
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$oldBugs = $this->getByIdList($bugIdList);
|
||||
$unlinkPlans = array();
|
||||
$link2Plans = array();
|
||||
foreach($bugIdList as $bugID)
|
||||
{
|
||||
$oldBug = $oldBugs[$bugID];
|
||||
if($planID == $oldBug->plan) continue;
|
||||
|
||||
/* Bugs link to plans and bugs unlink to plans. */
|
||||
$unlinkPlans[$oldBug->plan] = empty($unlinkPlans[$oldBug->plan]) ? $bugID : "{$unlinkPlans[$oldBug->plan]},$bugID";
|
||||
$link2Plans[$planID] = empty($link2Plans[$planID]) ? $bugID : "{$link2Plans[$planID]},$bugID";
|
||||
|
||||
/* Update bug plan. */
|
||||
$bug = new stdclass();
|
||||
$bug->plan = $planID;
|
||||
$this->bugTao->updateByID((int)$bugID, $bug);
|
||||
if(!dao::isError())
|
||||
{
|
||||
$changes = common::createChanges($oldBug, $bug);
|
||||
$actionID = $this->action->create('bug', $bugID, 'Edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Record plan action. */
|
||||
if(!dao::isError())
|
||||
{
|
||||
foreach($unlinkPlans as $planID => $bugs) $this->action->create('productplan', $planID, 'unlinkbug', '', $bugs);
|
||||
foreach($link2Plans as $planID => $bugs) $this->action->create('productplan', $planID, 'linkbug', '', $bugs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量解决bug。
|
||||
* Batch resolve bugs.
|
||||
|
||||
@@ -246,7 +246,7 @@ formBatchPanel
|
||||
on::change('[data-name="project"]', 'loadProductExecutionsByProject'),
|
||||
on::change('[data-name="execution"]', 'loadExecutionBuilds'),
|
||||
on::change('[data-name="region"]', 'setLane'),
|
||||
formHidden('product', $productID),
|
||||
formHidden('product', $product->id),
|
||||
);
|
||||
|
||||
render();
|
||||
|
||||
@@ -2279,4 +2279,45 @@ class bugZen extends bug
|
||||
|
||||
return $bugs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改bug计划。
|
||||
* Batch change the plan of bug.
|
||||
*
|
||||
* @param array $bugIdList
|
||||
* @param int $planID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
protected function batchChangePlan(array $bugIdList, int $planID): bool
|
||||
{
|
||||
$oldBugs = $this->bug->getByIdList($bugIdList);
|
||||
$unlinkPlans = array();
|
||||
$link2Plans = array();
|
||||
foreach($bugIdList as $bugID)
|
||||
{
|
||||
$oldBug = $oldBugs[$bugID];
|
||||
if($planID == $oldBug->plan) continue;
|
||||
|
||||
/* Bugs link to plans and bugs unlink to plans. */
|
||||
$unlinkPlans[$oldBug->plan] = empty($unlinkPlans[$oldBug->plan]) ? $bugID : "{$unlinkPlans[$oldBug->plan]},$bugID";
|
||||
$link2Plans[$planID] = empty($link2Plans[$planID]) ? $bugID : "{$link2Plans[$planID]},$bugID";
|
||||
|
||||
/* Update bug plan. */
|
||||
$bug = new stdclass();
|
||||
$bug->id = $bugID;
|
||||
$bug->plan = $planID;
|
||||
|
||||
$this->bug->update($bug);
|
||||
}
|
||||
|
||||
if(dao::isError()) return false;
|
||||
|
||||
/* Record plan action. */
|
||||
$this->loadModel('action');
|
||||
foreach($unlinkPlans as $planID => $bugs) $this->action->create('productplan', $planID, 'unlinkbug', '', $bugs);
|
||||
foreach($link2Plans as $planID => $bugs) $this->action->create('productplan', $planID, 'linkbug', '', $bugs);
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user