- Remove doc::getAllLibsByType method and unit test.

This commit is contained in:
tianshujie
2023-12-08 15:17:33 +08:00
parent 0e8eee0647
commit da1b45982f
3 changed files with 0 additions and 115 deletions
-58
View File
@@ -1243,64 +1243,6 @@ class docModel extends model
return false;
}
/**
* Get all libs by type.
*
* @param string $type
* @param int $pager
* @param string $extra
* @access public
* @return array
*/
public function getAllLibsByType($type, $pager = null, $product = '')
{
if($product and $type == 'execution') $executions = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->eq($product)->fetchPairs('project', 'project');
$libs = $this->getLibs($type == 'collector' ? 'all' : $type);
$key = ($type == 'product' or $type == 'execution') ? $type : 'id';
$stmt = $this->dao->select("DISTINCT $key")->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere('vision')->eq($this->config->vision);
if($type == 'product' or $type == 'execution')
{
$stmt = $stmt->andWhere($type)->ne(0);
}
elseif($type == 'collector')
{
$stmt = $stmt->andWhere('collector')->like("%,{$this->app->user->account},%");
}
else
{
$stmt = $stmt->andWhere('type')->eq($type);
}
if(isset($executions)) $stmt = $stmt->andWhere('execution')->in($executions);
$idList = $stmt->andWhere('id')->in(array_keys($libs))->orderBy("{$key}_desc")->fetchPairs($key, $key);
if($type == 'product' or $type == 'execution')
{
$orderBy = '`order` desc, id desc';
if($type == 'execution')
{
$project = $this->loadModel('project')->getByID($this->session->project);
$orderBy = (isset($project->model) and $project->model) == 'waterfall' ? 'begin_asc,id_asc' : 'begin_desc,id_desc';
}
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
$fields = $type == 'product' ? "createdBy, createdDate" : "openedBy AS createdBy, openedDate AS createdDate";
$libs = $this->dao->select("id, name, `order`, {$fields}")->from($table)
->where('id')->in($idList)
->beginIF($type == 'execution' and strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('status')->notin('done,closed')->fi()
->orderBy($orderBy)
->page($pager, 'id')
->fetchAll('id');
}
else
{
$libs = $this->dao->select('id, name, collector')->from(TABLE_DOCLIB)->where('id')->in($idList)->orderBy('`order`, id desc')->page($pager, 'id')->fetchAll('id');
}
return $libs;
}
/**
* Get all lib groups.
*
-18
View File
@@ -255,24 +255,6 @@ class docTest
return $data[0];
}
/**
* Function getAllLibsByType test by doc
*
* @param mixed $type
* @param mixed $product
* @param mixed $pager
* @access public
* @return void
*/
public function getAllLibsByTypeTest($type, $product, $pager = null)
{
$objects = $this->objectModel->getAllLibsByType($type, $pager, $product);
if(dao::isError()) return dao::getError();
return $objects;
}
/**
* Test stat module and document counts of lib.
*
@@ -1,39 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/doc.class.php';
su('admin');
/**
title=测试 docModel->getAllLibsByType();
cid=1
pid=1
collector类型查询 >> 0
all类型查询 >> 0
product类型查询 >> 正常产品2,po2
product类型传入产品id查询 >> 正常产品3,po3
product类型查询统计 >> 100
product类型传入产品id查询统计 >> 100
execution类型查询 >> 迭代1,
execution类型传入产品id查询 >> 看板62,
execution类型查询统计 >> 14
execution类型传入产品id查询统计 >> 630
*/
$types = array('collector', 'all', 'product', 'execution');
$product = array('1', '');
$doc = new docTest();
r($doc->getAllLibsByTypeTest($types[0], $product[0])) && p() && e('0'); //collector类型查询
r($doc->getAllLibsByTypeTest($types[1], $product[0])) && p() && e('0'); //all类型查询
r($doc->getAllLibsByTypeTest($types[2], $product[0])) && p('2:name,createdBy') && e('正常产品2,po2');//product类型查询
r($doc->getAllLibsByTypeTest($types[2], $product[1])) && p('3:name,createdBy') && e('正常产品3,po3');//product类型传入产品id查询
r(count($doc->getAllLibsByTypeTest($types[2], $product[0]))) && p() && e('100'); //product类型查询统计
r(count($doc->getAllLibsByTypeTest($types[2], $product[1]))) && p() && e('100'); //product类型传入产品id查询统计
r($doc->getAllLibsByTypeTest($types[3], $product[0])) && p('101:name,createdBy') && e('迭代1,'); //execution类型查询
r($doc->getAllLibsByTypeTest($types[3], $product[1])) && p('162:name,createdBy') && e('看板62,'); //execution类型传入产品id查询
r(count($doc->getAllLibsByTypeTest($types[3], $product[0]))) && p() && e('14'); //execution类型查询统计
r(count($doc->getAllLibsByTypeTest($types[3], $product[1]))) && p() && e('630'); //execution类型传入产品id查询统计