From 286516089524af07940a2ecddbbf58c58fac3465 Mon Sep 17 00:00:00 2001 From: Chenjianyu Date: Thu, 3 Aug 2023 16:36:58 +0800 Subject: [PATCH] * prompt audit go straight to the execution page. --- module/ai/model.php | 58 +++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/module/ai/model.php b/module/ai/model.php index 2c3d21dd42..e62d3ff5da 100644 --- a/module/ai/model.php +++ b/module/ai/model.php @@ -942,78 +942,69 @@ class aiModel extends model { return helper::createLink('my', 'effort', "type=all"); } - if($module == 'product') + else if($module == 'product') { - $productId = $this->dao->select('max(id) as maxId')->from(TABLE_PRODUCT) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_PRODUCT) ->where('id')->in($this->app->user->view->products) ->fetch('maxId'); - if(!empty($productId)) return helper::createLink('product', 'view', "productID=$productId"); } - if($module == 'productplan') + else if($module == 'productplan') { - $productplanId = $this->dao->select('max(id) as maxId')->from(TABLE_PRODUCTPLAN) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_PRODUCTPLAN) ->where('product')->in($this->app->user->view->products) ->fetch('maxId'); - if(!empty($productplanId)) return helper::createLink('productplan', 'view', "productplanID=$productplanId"); - }; - if($module == 'release') + } + else if($module == 'release') { - $releaseId = $this->dao->select('max(id) as maxId')->from(TABLE_RELEASE) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_RELEASE) ->where('project')->in($this->app->user->view->projects) ->orWhere('product')->in($this->app->user->view->products) ->fetch('maxId'); - if(!empty($releaseId)) return helper::createLink('release', 'view', "releaseID=$releaseId"); } - if($module == 'project') + else if($module == 'project') { - $projectId = $this->dao->select('max(id) as maxId')->from(TABLE_PROJECT) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_PROJECT) ->where('id')->in($this->app->user->view->projects) ->fetch('maxId'); - if(!empty($projectId)) return helper::createLink('project', 'view', "projectID=$projectId"); } - if($module == 'story') + else if($module == 'story') { - $storyId = $this->dao->select('max(id) as maxId')->from(TABLE_STORY) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_STORY) ->where('product')->in($this->app->user->view->products) ->fetch('maxId'); - if(!empty($storyId)) return helper::createLink('story', 'view', "storyID=$storyId"); } - if($module == 'execution') + else if($module == 'execution') { $executionIds = array_map('intval', explode(',', $this->app->user->view->sprints)); - $executionId = max($executionIds); - if(!empty($executionId)) return helper::createLink('execution', 'view', "executionID=$executionId"); + $objectId = max($executionIds); } - if($module == 'task') + else if($module == 'task') { - $taskId = $this->dao->select('max(id) as maxId')->from(TABLE_TASK) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_TASK) ->where('project')->in($this->app->user->view->projects) ->fetch('maxId'); - if(!empty($taskId)) return helper::createLink('task', 'view', "taskID=$taskId"); } - if($module == 'case') + else if($module == 'case') { - $caseId = $this->dao->select('max(id) as maxId')->from(TABLE_CASE) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_CASE) ->where('project')->in($this->app->user->view->projects) ->orWhere('product')->in($this->app->user->view->products) ->fetch('maxId'); - if(!empty($caseId)) return helper::createLink('testcase', 'view', "caseID=$caseId"); } - if($module == 'bug') + else if($module == 'bug') { - $bugId = $this->dao->select('max(id) as maxId')->from(TABLE_BUG) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_BUG) ->where('project')->in($this->app->user->view->projects) ->orWhere('product')->in($this->app->user->view->products) ->fetch('maxId'); - if(!empty($bugId)) return helper::createLink('bug', 'view', "bugID=$bugId"); } - if($module == 'doc') + else if($module == 'doc') { - $docId = $this->dao->select('max(id) as maxId')->from(TABLE_DOC) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_DOC) ->where('project')->in($this->app->user->view->projects) ->orWhere('product')->in($this->app->user->view->products) ->fetch('maxId'); - if(empty($docId)) + if(empty($objectId)) { $userDocLibs = $this->dao->select('id')->from(TABLE_DOCLIB) ->where('type')->eq('mine') @@ -1021,14 +1012,15 @@ class aiModel extends model ->fetchPairs(); if(!empty($userDocLibs)) { - $docId = $this->dao->select('max(id) as maxId')->from(TABLE_DOC) + $objectId = $this->dao->select('max(id) as maxId')->from(TABLE_DOC) ->where('lib')->in($userDocLibs) ->fetch('maxId'); } } - if(!empty($docId)) return helper::createLink('doc', 'view', "docID=$docId"); } + if(!empty($objectId)) return helper::createLink('ai', 'promptexecute', "promptId=$prompt->id&objectId=$objectId"); + return false; }