禅道bug增加自定义字段

news/2024/12/23 20:54:05/文章来源:https://www.cnblogs.com/mua9102/p/18618101

禅道版本

18.9

需求

给禅道的bug模块,增加自定义字段。

  1. 目前主要增加“发现阶段”、“所属环境”、“出现频率”
  2. 增加bug的类型
  3. 在bug列表增加搜索:“发现阶段”、“所属环境”、“出现频率”
  4. 在测试报告增加模块:“发现阶段”、“所属环境”、“出现频率”

禅道开发手册

https://www.zentao.net/book/extension-new/intro-1256.html

具体步骤

修改bug模块的

module\bug

增加字段(对应数据库的)

module\bug\lang\zh-cn.php

# 33行(基础字段)
$lang->bug->period           = '发现阶段';
$lang->bug->environment      = '所属环境';
$lang->bug->frequency        = '出现频率';# 231行(发现阶段的可选项)
/*bug发现阶段*/
$lang->bug->periodList['']          = '';
$lang->bug->periodList['plan']      = '计划阶段';
$lang->bug->periodList['design']    = '设计阶段';
$lang->bug->periodList['dev']       = '开发阶段';
$lang->bug->periodList['smoke']     = '冒烟阶段';
$lang->bug->periodList['test']      = '测试阶段';
$lang->bug->periodList['alpha']     = 'alpha测试阶段';
$lang->bug->periodList['beta']      = 'beta测试阶段';
$lang->bug->periodList['uat']       = 'uat测试阶段';
$lang->bug->periodList['prod']      = '生产阶段';
$lang->bug->periodList['reg']       = '回归阶段';
$lang->bug->periodList['ato']       = '自动化测试';# 246行(发现环境的可选项)
/*bug所属环境*/
$lang->bug->environmentList['']     = '';
$lang->bug->environmentList['dev']  = '开发环境';
$lang->bug->environmentList['test'] = '测试环境';
$lang->bug->environmentList['stag'] = '预发布环境';
$lang->bug->environmentList['prod'] = '生产环境';
$lang->bug->environmentList['dre']  = '灾备环境';# 253行(出现频率的可选项)
/*bug出现频率*/
$lang->bug->frequencyList[''] = '';
$lang->bug->frequencyList['always'] = '必现';
$lang->bug->frequencyList['high']   = '高频';
$lang->bug->frequencyList['low']    = '低频';
$lang->bug->frequencyList['once']   = '1次';#261行
/* 各个字段取值列表。*/
$lang->bug->severityList[0] = '';
$lang->bug->severityList[1] = '致命';
$lang->bug->severityList[2] = '严重';
$lang->bug->severityList[3] = '一般';
$lang->bug->severityList[4] = '优化';$lang->bug->priList[0] = '';
$lang->bug->priList[1] = '急';
$lang->bug->priList[2] = '高';
$lang->bug->priList[3] = '中';
$lang->bug->priList[4] = '低';# 307行(增加bug类型)
$lang->bug->typeList['']             = '';
$lang->bug->typeList['designdefect'] = '设计缺陷';
$lang->bug->typeList['codeerror']    = '代码错误';
$lang->bug->typeList['config']       = '配置问题';
$lang->bug->typeList['operation']    = '操作问题';
$lang->bug->typeList['UI']           = 'UI问题';
$lang->bug->typeList['MINIAPP']      = '小程序问题';
$lang->bug->typeList['APP']          = 'APP问题';
$lang->bug->typeList['front']        = '前端问题';
$lang->bug->typeList['back']         = '后端问题';
$lang->bug->typeList['data']         = '数据问题';
$lang->bug->typeList['addRequire']   = '新增需求';
$lang->bug->typeList['compatibility']= '兼容问题';
$lang->bug->typeList['install']      = '安装部署';
$lang->bug->typeList['performance']  = '性能问题';
$lang->bug->typeList['security']     = '安全问题';
$lang->bug->typeList['standard']     = '标准规范';
$lang->bug->typeList['automation']   = '测试脚本';
$lang->bug->typeList['others']       = '其他';# 370行(测试报告的图表)
$lang->bug->report->charts['bugsPeriod']            = '按发现阶段统计';
$lang->bug->report->charts['bugsEnvironment']       = '按所属环境统计';
$lang->bug->report->charts['bugsFrequency']         = '按发生频率统计';# 499行(测试报告的对象)
$lang->bug->report->bugsPeriod            = new stdclass();
$lang->bug->report->bugsEnvironment       = new stdclass();
$lang->bug->report->bugsFrequency         = new stdclass();# 422行(测试报告的图表对象)
$lang->bug->report->bugsPeriod->graph            = new stdclass();
$lang->bug->report->bugsEnvironment->graph       = new stdclass();
$lang->bug->report->bugsFrequency->graph         = new stdclass();# 453行
$lang->bug->report->bugsPeriod->graph->xAxisName            = '发现阶段';
$lang->bug->report->bugsEnvironment->graph->xAxisName       = '所属环境';
$lang->bug->report->bugsFrequency->graph->xAxisName         = '发生频率';

修改配置层

config.php

module\bug\config.php

# 8行 bug必填字段(新增的字段,不建议搞成必填,这里只做示范)
// $config->bug->create->requiredFields  = 'title,openedBuild,period,environment,frequency';
$config->bug->create->requiredFields  = 'title,openedBuild';
$config->bug->edit->requiredFields    = $config->bug->create->requiredFields;
// $config->bug->resolve->requiredFields = 'resolution,period,environment,frequency';
$config->bug->resolve->requiredFields = 'resolution';# 15行 bug全部字段
$config->bug->list->allFields = 'id, module, execution, story, task,title, keywords, severity, pri, type, os, browser, period, environment, frequency, hardware,found, steps, status, deadline, activatedCount, confirmed, mailto,openedBy, openedDate, openedBuild,assignedTo, assignedDate,resolvedBy, resolution, resolvedBuild, resolvedDate,closedBy, closedDate,duplicateBug, linkBug,case,lastEditedBy,lastEditedDate';# 28行 bug导出csv字段
$config->bug->exportFields = 'id, product, branch, module, project, execution, story, task,title, keywords, severity, pri, type, os, browser, period, environment, frequency,steps, status, deadline, activatedCount, confirmed, mailto,openedBy, openedDate, openedBuild,assignedTo, assignedDate,resolvedBy, resolution, resolvedBuild, resolvedDate,closedBy, closedDate,duplicateBug, linkBug,case,lastEditedBy,lastEditedDate, files ,feedbackBy, notifyEmail';# 45行
$config->bug->list->customBatchEditFields   = 'type,severity,pri,productplan,assignedTo,deadline,resolvedBy,resolution,os,browser,environment,keywords';
$config->bug->list->customBatchCreateFields = 'project,execution,steps,type,pri,deadline,severity,os,browser,environment,keywords';# 91行 bug列表搜索字段
$config->bug->search['fields']['period']         = $lang->bug->period;
$config->bug->search['fields']['environment']    = $lang->bug->environment;
$config->bug->search['fields']['frequency']      = $lang->bug->frequency;# 141行 bug搜索字段可选项
$config->bug->search['params']['period']        = array('operator' => 'include', 'control' => 'select', 'values' => $lang->bug->periodList);
$config->bug->search['params']['environment']   = array('operator' => 'include', 'control' => 'select', 'values' => $lang->bug->environmentList);
$config->bug->search['params']['frequency']     = array('operator' => 'include', 'control' => 'select', 'values' => $lang->bug->frequencyList);# 164行 bug列表中,默认的展示字段(只新加了“所属环境”)
$config->bug->datatable->defaultField = array('id', 'title', 'severity', 'pri', 'status', 'environment', 'openedBy', 'openedDate', 'confirmed', 'assignedTo', 'resolution', 'actions');# 214行 bug列表中,“所属环境”字段的HTML配置信息
$config->bug->datatable->fieldList['environment']['title']    = 'environment';
$config->bug->datatable->fieldList['environment']['type']     = 'html';
$config->bug->datatable->fieldList['environment']['fixed']    = 'no';
$config->bug->datatable->fieldList['environment']['width']    = '80';
$config->bug->datatable->fieldList['environment']['sortType'] = true;
$config->bug->datatable->fieldList['environment']['show']     = true;
$config->bug->datatable->fieldList['environment']['control']  = 'multiple';

table.php

module\bug\config\table.php

# 4行,增加 environment
$config->bug->dtable->defaultField = array('id', 'title', 'severity', 'pri', 'status','environment', 'openedBy', 'openedDate', 'confirmed', 'assignedTo', 'resolution', 'actions');# 36行,增加environment
$config->bug->dtable->fieldList['environment']['title'] = $lang->bug->environment;
$config->bug->dtable->fieldList['environment']['type']  = 'category';
$config->bug->dtable->fieldList['environment']['map']   = $lang->bug->environmentList;
$config->bug->dtable->fieldList['environment']['group'] = 7;

修改控制层

module\bug\control.php

# 693行$this->view->period                = $period;$this->view->environment           = $environment;$this->view->frequency             = $frequency;

修改模型层

module\bug\model.php

# 56行 create方法,增加字段
## 68行->setDefault('period', '')->setDefault('frequency', '')
## 81行->join('period', '')->join('environment', ',')->join('frequency', '')# 161行 batchCreate方法,增加字段
## 197行$environments = array_filter($data->environments[$i]);
## 217行$data->environments[$i] = implode(',', $environments);
## 248行$bug->environment = $data->environments[$i];# 738行 update方法,增加字段
## 755行->setDefault('period', '')->setDefault('environment', '')->setDefault('frequency', '')
## 766行->join('period', '')->join('environment', ',')->join('frequency', '')# 864 batchUpdate方法,增加字段
## 914行$environments = array_filter($data->environments[$bugID]);
## 935行$bug->environment = implode(',', $environments);# 2312行 getBugInfoFromResult方法,增加字段
# 2369行 测试报告/*** Get report data of bugs period* 根据发现阶段获取报表* @access public* @rerturn array*/public function getDataOfbugsPeriod(){$datas = $this->dao->select('period AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');if (!$datas)return array();foreach ($datas as $period => $data)if (isset($this->lang->bug->periodList[$period]))$data->name = $this->lang->bug->periodList[$period];return $datas;}/*** Get report data of bugs environment* 根据所属环境获取报表* @access public* @rerturn array*/public function getDataOfBugsEnvironment(){$datas = $this->dao->select('environment AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');if (!$datas)return array();foreach ($datas as $environment => $data)if (isset($this->lang->bug->environmentList[$environment]))$data->name = $this->lang->bug->environmentList[$environment];return $datas;}/*** Get report data of bugs frequency* 根据发生频率获取报表* @access public* @rerturn array*/public function getDataOfBugsFrequency(){$datas = $this->dao->select('frequency AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');if (!$datas)return array();foreach ($datas as $frequency => $data)if (isset($this->lang->bug->frequencyList[$frequency]))$data->name = $this->lang->bug->frequencyList[$frequency];return $datas;}# 因为所属环境,可以多选,所以要修改一下地方
# 3443行,printCell方法
## 3476行$environment = '';$environmentList = explode(',', $bug->environment);
## 3487行foreach ($environmentList as $value) {if (empty($value))continue;$environment .= zget($this->lang->bug->environmentList, $value) . ',';}
## 3494行$environment = trim($environment, ',');
## 3554行case 'environment':$class .= ' text-ellipsis';$title = "title='" . $environment . "'";break;
## 3662行case 'environment':echo $environment;break;# 4099行 generateRow方法
## 4175行$bugEnvironment = array();if ($bug->environment) {foreach (explode(',', $bug->environment) as $environment) {$environment = trim($environment);if ($environment)$bugEnvironment[] = zget($this->lang->bug->environmentList, $environment, '');}}$bug->environment = implode(',', $bugEnvironment);## 4027行,增加foreach (array_merge(array('os', 'browser', 'environment', 'mailto', 'branch', 'project', 'plan', 'execution', 'type', 'resolution', 'keywords', 'openedBuild', 'resolvedBuild', 'activatedCount'), $userFields, $dateFields) as $field) {if (empty($bug->$field))continue;

修改视图层

create.html.php

module\bug\view\create.html.php

# 225行<td><div class='table-row'><div class='table-col' id='periodBox'><div class='input-group'><span class='input-group-addon'><?php echo $lang->bug->period ?></span><?php echo html::select('period', $lang->bug->periodList, $period, "class='form-control chosen'"); ?></div></div><div class='table-col' id='environmentBox'><div class='input-group'><span class='input-group-addon fix-border'><?php echo $lang->bug->environment ?></span><?php echo html::select('environment[]', $lang->bug->environmentList, $environment, "class='form-control chosen' multiple"); ?></div></div><div class='table-col' id='frequencyBox'><div class='input-group'><span class='input-group-addon'><?php echo $lang->bug->frequency ?></span><?php echo html::select('frequency', $lang->bug->frequencyList, $frequency, "class='form-control chosen'"); ?></div></div></div></td>

image

edit.html.php

# 36行
js::set('period', $bug->period);
js::set('environment', $bug->environment);
js::set('frequency', $bug->frequency);# 268行<tr><th><?php echo $lang->bug->period; ?></th><td><?php echo html::select('period', $lang->bug->periodList, $bug->period, "class='form-control chosen'"); ?></td></tr><tr><th><?php echo $lang->bug->environment; ?></th><td><?php echo html::select('environment[]', $lang->bug->environmentList, $bug->environment, "class='form-control chosen' multiple"); ?></td></tr><tr><th><?php echo $lang->bug->frequency; ?></th><td><?php echo html::select('frequency', $lang->bug->frequencyList, $bug->frequency, "class='form-control chosen'"); ?></td></tr>

image

view.html.php

# 361行<tr><th><?php echo $lang->bug->period; ?></th><td><?php if (isset($lang->bug->periodList[$bug->period]))echo $lang->bug->periodList[$bug->period];elseecho $bug->period; ?></td></tr><tr><th><?php echo $lang->bug->environment; ?></th><td><?php $environmentList = explode(',', $bug->environment); ?><?php if ($environmentList): ?><p class='browserContent'><?php foreach ($environmentList as $environment): ?><?php if ($environment)echo "<span class='label label-outline'>" . zget($lang->bug->environmentList, $environment) . "</span>"; ?><?php endforeach; ?></p><?php endif; ?></td></tr><tr><th><?php echo $lang->bug->frequency; ?></th><td><?php if (isset($lang->bug->frequencyList[$bug->frequency]))echo $lang->bug->frequencyList[$bug->frequency];elseecho $bug->frequency; ?></td></tr>

image

batchcreate.html.php

module\bug\view\batchcreate.html.php

# 76行 <th class='c-environment<?php echo zget($visibleFields, 'environment', ' hidden') . zget($requiredFields, 'environment', '', ' required');?> environmentBox'><?php echo $lang->bug->environment;?></th># 139行<td class='<?php echo zget($visibleFields, 'environment', 'hidden')?> environmentBox' style='overflow:visible'> <?php echo html::select("environments[$i][]", $lang->bug->environmentList, '', "class='form-control chosen' multiple");?></td># 195行<td class='<?php echo zget($visibleFields, 'environment', 'hidden')?> environmentBox' style='overflow:visible'> <?php echo html::select("environments[$i][]", $lang->bug->environmentList, '', "class='form-control chosen' multiple");?></td># 254行<td class='<?php echo zget($visibleFields, 'environment', 'hidden')?> environmentBox' style='overflow:visible'> <?php echo html::select("environments[%s][]", $lang->bug->environmentList, '', "class='form-control chosen' multiple");?></td># 301行<td class='<?php echo zget($visibleFields, 'environment', 'hidden')?> environmentBox' style='overflow:visible'> <?php echo html::select("environments[$i][]", $lang->bug->environmentList, '', "class='form-control chosen' multiple");?></td>

batchcreate.css

module\bug\css\batchcreate.css

.c-steps, .c-environment {width: 150px;}

image

batchedit.html.php

module\bug\view\batchedit.html.php

# 66行<th class='c-environment<?php echo zget($visibleFields, 'environment', ' hidden') . zget($requiredFields, 'environment', '', ' required');?>'><?php echo $lang->bug->environment;?></th># 111行<td <?php echo zget($visibleFields, 'environment', "class='hidden'")?>><?php echo html::select("environments[$bugID][]", $lang->bug->environmentList, $bug->environment, 'class="form-control chosen" multiple');?></td>

batchedit.css

module\bug\css\batchedit.css

.c-steps, .c-title, .c-plan, .c-assigned, .c-resolution, .c-environment {width: 150px;}

修复他们官方的bug

module\bug\js\batchedit.js

# 27行,添加:(this).data('zui.picker') && if($(this).data('zui.picker') && $(this).data('zui.picker').getValue() == 'ditto')

image

修改testreport模块的

module\testreport

修改数据库

module\testreport\lang\zh-cn.php

# 66行
$lang->testreport->bugPeriodGroups     = 'Bug发现阶段分布';
$lang->testreport->bugEnvironmentGroups     = 'Bug所属环境分布';
$lang->testreport->bugFrequencyGroups     = 'Bug发生频率分布';

修改模型层

module\testreport\model.php

# 149行$severityGroups = $statusGroups = $openedByGroups = $resolvedByGroups = $resolutionGroups = $moduleGroups = $typeGroups = $stageGoups = $handleGroups = $periodGroups = $environmentGroups = $frequencyGroups = array();# 264行### 增加 发现阶段、所属模块、发生频率$periodGroups[$bug->period]     = isset($periodGroups[$bug->period])     ? $periodGroups[$bug->period]     + 1 : 1;$environmentGroups[$bug->environment]     = isset($environmentGroups[$bug->environment])     ? $environmentGroups[$bug->environment]     + 1 : 1;$frequencyGroups[$bug->frequency]     = isset($frequencyGroups[$bug->frequency])     ? $frequencyGroups[$bug->frequency]     + 1 : 1;# 331行## 新增发现阶段、所属环境、发生频率$data  = array();foreach($periodGroups as $period => $count){$data[$period] = new stdclass();$data[$period]->name  = zget($this->lang->bug->periodList, $period);$data[$period]->value = $count;}$bugInfo['bugPeriodGroups'] = $data;$data  = array();foreach($environmentGroups as $environment => $count){$data[$environment] = new stdclass();$data[$environment]->name  = zget($this->lang->bug->environmentList, $environment);$data[$environment]->value = $count;}$bugInfo['bugEnvironmentGroups'] = $data;$data  = array();foreach($frequencyGroups as $frequency => $count){$data[$frequency] = new stdclass();$data[$frequency]->name  = zget($this->lang->bug->frequencyList, $frequency);$data[$frequency]->value = $count;}$bugInfo['bugFrequencyGroups'] = $data;

image

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/857656.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

php网络编程tcp

服务端:<?php $server = new Swoole\Server(127.0.0.1, 9501);$server->set([worker_num => 8, // worker进程数 cpu1-4倍max_request => 10000, // 根据内存定义 https://wiki.swoole.com/#/server/setting// open_eof_check => true,// package_eof => &…

php网络编程swoole websocket

服务端:<?php use Swoole\WebSocket\Server;// 创建 HTTP 服务器 $server = new Server(127.0.0.1, 8888, SWOOLE_PROCESS, SWOOLE_SOCK_TCP);$server->on(start, function ($server) {//print_r($server);echo "Swoole websocket server is started at ws://127.…

php网络编程swoole udp

服务端:<?php $server = new Swoole\Server(127.0.0.1, 9504, SWOOLE_PROCESS, SWOOLE_SOCK_UDP);$server->on(start, function ($server) {echo "UDP Server is started at udp://127.0.0.1:9504\n"; });$server->on(packet, function ($server, $data, …

第36次ccf-csp题解(思维)

比赛链接 https://sim.csp.thusaac.com/contest/36/home比赛感受这会刚打完上海icpc,比起区域赛的题,这个简单太多了。 感受还不错,写的很顺手。除了第3题,其他3题都是一发过。 刷题得长期刷。 A题 移动题意:f : y+1 ;  b : y-1 ;   l : x-1 ;  r : x+1 一个简单的模…

php网络编程swoole http

服务端:<?php use Swoole\Http\Server; use Swoole\Http\Request; use Swoole\Http\Response;// 创建 HTTP 服务器 $server = new Server(127.0.0.1, 9501);$server->on(start, function ($server) {//print_r($server);echo "Swoole http server is started at h…

JVM简介—2.垃圾回收器和内存分配策略

大纲 1.垃圾回收概述 2.如何判断对象存活 3.各种引用介绍 4.垃圾收集的算法 5.垃圾收集器的设计 6.垃圾回收器列表 7.各种垃圾回收器详情 8.Stop The World现象 9.内存分配与回收策略 10.新生代不同配置演示 11.内存泄漏和内存溢出 12.JDK为提供的工具1.垃圾回收概述 2.如何判…

OpenAI 推出嵌入式硬件 SDK,支持 ESP32 语音开发;INFP:音频驱动的双人对话头像生成,自动区分说话者和倾听者

开发者朋友们大家好:这里是 「RTE 开发者日报」,每天和大家一起看新闻、聊八卦。我们的社区编辑团队会整理分享 RTE(Real-Time Engagement) 领域内「有话题的 新闻 」、「有态度的 观点 」、「有意思的 数据 」、「有思考的 文章 」、「有看点的 会议 」,但内容仅代表编辑…

8086汇编(16位汇编)学习笔记02.分段,机器码和寻址

原文链接:https://bpsend.net/thread-112-1-2.html 分段问题1 8086是16位cpu,最多可以访问(寻址)多大内存?运算器一次最多处理16位的数据。地址寄存器的最大宽度为16位。访问的最大内存为:216 = 64K 即 0000 - FFFF。问题2 8086允许最大内存1M,如何实现访问(寻址)到所…

AI对话机器人续:将AI Bot接入企业微信

之前尝试将Coze AI Bot接入到了微信,有朋友问如何接入企业微信,今天有空尝试了下,和你分享一下过程。整体流程和步骤还是基于chatgpt-on-wechat这个开源框架来的,唯一的差别就在于部署chatgpt-on-wechat的时候,需要填写一些企业微信相关的参数和secret。大家好,我是Ediso…

python网络编程之udp

服务端:import socketsk = socket.socket(type=socket.SOCK_DGRAM) # 表示一个udp协议 sk.bind((127.0.0.1, 9504))# 服务端不能先发送消息,因为服务端不知道客户端的ip while True:msg, addr = sk.recvfrom(1024)print(f"接收到客户端数据:{msg.decode(utf-8)}"…

Qt编程快速入门(1)Qt结构简介

Qt构成Qt(/ˈkjuːt/,发音同“cute”)是一个跨平台的C++应用程序开发框架。广泛用于开发GUI程序,这种情况下又被称为部件工具箱。也可用于开发非GUI程序,例如控制台工具和服务器。-摘自维基百科Qt可以在多个平台编译运行,包括Windows、Linux、Mac OS,其运行时的表现取决…

python网络编程之websocket

服务端:import asyncio import websockets# 保存已连接的客户端列表 connected_clients = set()async def handle_websocket(websocket):# 将新的客户端添加到已连接客户端列表remote_address = websocket.remote_addressconnected_clients.add(websocket)print(f"新的客…