diff --git a/module/job/control.php b/module/job/control.php index ba504da717..332b0a695a 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -123,7 +123,7 @@ class job extends control $this->view->products = array(0 => '') + $this->loadModel('product')->getProductPairsByProject($this->projectID); $this->view->jenkinsServerList = array('' => '') + $this->loadModel('jenkins')->getPairs(); - $this->view->sonarqubeServerList = array('') + $this->loadModel('sonarqube')->getPairs(); + $this->view->sonarqubeServerList = array('') + $this->loadModel('pipeline')->getPairs('sonarqube'); $this->display(); } @@ -204,7 +204,7 @@ class job extends control $this->view->job = $job; $this->view->products = array('') + $products; $this->view->jenkinsServerList = $this->loadModel('jenkins')->getPairs(); - $this->view->sonarqubeServerList = array('') + $this->loadModel('sonarqube')->getPairs(); + $this->view->sonarqubeServerList = array('') + $this->loadModel('pipeline')->getPairs('sonarqube'); $this->view->pipelines = $this->jenkins->getTasks($job->server); $this->display(); diff --git a/module/job/model.php b/module/job/model.php index 1e416f67da..d9b60f64b5 100644 --- a/module/job/model.php +++ b/module/job/model.php @@ -624,15 +624,16 @@ class jobModel extends model * @param int $sonarqubeID * @param array $projectKeys * @param bool $emptyShowAll + * @param bool $showDeleted * @access public * @return array */ - public function getJobBySonarqubeProject($sonarqubeID, $projectKeys = array(), $emptyShowAll = false) + public function getJobBySonarqubeProject($sonarqubeID, $projectKeys = array(), $emptyShowAll = false, $showDeleted = false) { return $this->dao->select('projectKey,id')->from(TABLE_JOB) - ->where('deleted')->eq(0) - ->andWhere('frame')->eq('sonarqube') + ->where('frame')->eq('sonarqube') ->andWhere('sonarqubeServer')->eq($sonarqubeID) + ->beginIF(!$showDeleted)->andWhere('deleted')->eq('0')->fi() ->beginIF(!empty($projectKeys) or !$emptyShowAll)->andWhere('projectKey')->in($projectKeys)->fi() ->fetchPairs(); } diff --git a/module/sonarqube/control.php b/module/sonarqube/control.php index c0e3d22fac..0750efef68 100644 --- a/module/sonarqube/control.php +++ b/module/sonarqube/control.php @@ -40,7 +40,7 @@ class sonarqube extends control $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); - $sonarqubeList = $this->sonarqube->getList($orderBy, $pager); + $sonarqubeList = $this->loadModel('pipeline')->getList('sonarqube', $orderBy, $pager); $this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->browse; $this->view->sonarqubeList = $sonarqubeList; @@ -60,7 +60,7 @@ class sonarqube extends control */ public function ajaxGetProjectList($sonarqubeID, $projectKey = '') { - $jobPairs = $this->loadModel('job')->getJobBySonarqubeProject($sonarqubeID, array(), true); + $jobPairs = $this->loadModel('job')->getJobBySonarqubeProject($sonarqubeID, array(), true, true); $existsProject = array_diff(array_keys($jobPairs), array($projectKey)); $projectList = $this->sonarqube->apiGetProjects($sonarqubeID); @@ -138,13 +138,13 @@ class sonarqube extends control */ public function edit($sonarqubeID) { - $oldSonarQube = $this->sonarqube->getByID($sonarqubeID); + $oldSonarQube = $this->loadModel('pipeline')->getByID($sonarqubeID); if($_POST) { $this->checkToken($sonarqubeID); - $this->loadModel('pipeline')->update($sonarqubeID); - $sonarqube = $this->sonarqube->getByID($sonarqubeID); + $this->pipeline->update($sonarqubeID); + $sonarqube = $this->pipeline->getByID($sonarqubeID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action'); @@ -171,11 +171,11 @@ class sonarqube extends control { if($confirm != 'yes') die(js::confirm($this->lang->sonarqube->confirmDelete, inlink('delete', "sonarqubeID=$sonarqubeID&confirm=yes"))); - $oldSonarQube = $this->sonarqube->getByID($sonarqubeID); + $oldSonarQube = $this->loadModel('pipeline')->getByID($sonarqubeID); $this->loadModel('action'); - $actionID = $this->loadModel('pipeline')->delete($sonarqubeID, 'sonarqube'); + $actionID = $this->pipeline->delete($sonarqubeID, 'sonarqube'); - $sonarQube = $this->sonarqube->getByID($sonarqubeID); + $sonarQube = $this->pipeline->getByID($sonarqubeID); $changes = common::createChanges($oldSonarQube, $sonarQube); $this->action->logHistory($actionID, $changes); echo js::reload('parent'); @@ -229,7 +229,7 @@ class sonarqube extends control $pager = new pager($recTotal, $recPerPage, $pageID); $sonarqubeProjectList = array_chunk($sonarqubeProjectList, $pager->recPerPage); - $this->view->sonarqube = $this->sonarqube->getByID($sonarqubeID); + $this->view->sonarqube = $this->loadModel('pipeline')->getByID($sonarqubeID); $this->view->keyword = urldecode(urldecode($keyword)); $this->view->pager = $pager; $this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->browseProject; diff --git a/module/sonarqube/model.php b/module/sonarqube/model.php index ebdbddc79c..04b0a1012d 100644 --- a/module/sonarqube/model.php +++ b/module/sonarqube/model.php @@ -12,44 +12,6 @@ class sonarqubeModel extends model { - /** - * Get a sonarqube by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - return $this->loadModel('pipeline')->getByID($id); - } - - /** - * Get sonarqube list. - * - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getList($orderBy = 'id_desc', $pager = null) - { - $sonarqubeList = $this->loadModel('pipeline')->getList('sonarqube', $orderBy, $pager); - - return $sonarqubeList; - } - - /** - * Get sonarqube pairs. - * - * @access public - * @return array - */ - public function getPairs() - { - return $this->loadModel('pipeline')->getPairs('sonarqube'); - } - /** * Get sonarqube api base url and header by id. * @@ -59,7 +21,7 @@ class sonarqubeModel extends model */ public function getApiBase($sonarqubeID) { - $sonarqube = $this->getByID($sonarqubeID); + $sonarqube = $this->loadModel('pipeline')->getByID($sonarqubeID); if(!$sonarqube) return array('', array()); $url = rtrim($sonarqube->url, '/') . '/api/%s'; diff --git a/test/data/pipeline.yaml b/test/data/pipeline.yaml index db7e26cd29..60ad7e0b48 100644 --- a/test/data/pipeline.yaml +++ b/test/data/pipeline.yaml @@ -5,7 +5,7 @@ fields: - field: id range: 1-2 - field: type - range: gitlabi,sonarqube + range: gitlab,sonarqube - field: name range: gitlab服务器,sonarqube服务器 - field: url