def get_project_bug_resolve(self,mid):
     """
     返回某个项目当天解决的bug数量
     :param mid:
     :return:
     """
     name_sql = "select name FROM zt_project WHERE id = {}".format(mid)
     test_sql = "SELECT project, COUNT(id) from zt_bug WHERE project = {} AND DATE_FORMAT(resolvedDate,'%Y%m%d')= DATE_FORMAT(CURRENT_DATE,'%Y%m%d')  AND deleted = '0' AND status = 'resolved' or status = 'closed' GROUP BY project;;".format(
         mid)
     mydb = MyDbHelper("zentao")
     project = mydb.get_one(name_sql)
     result = mydb.get_all(test_sql)
     result[0].update({"项目名称": result[0].pop("project")})
     result[0].update({"当天解决bug数": result[0].pop("COUNT(id)")})
     result[0]['项目名称'] = project['name']
     a = dingRobot('test')
     title = ("当天解决的bug数汇总:\n")
     content = str(result[0])
     a.markdown(title,content)
    def get_test_bugs(self, mid):
        '''
        返回某个项目每天新增的bug数
        :param 版本id, 项目id:
        :return: ([{'project': 'mid', 'COUNT(id)': 新增bug数, 'openedBy': '提出者'}]
        '''
        name_sql = "select name FROM zt_project WHERE id = {}".format(mid)

        test_sql = ("SELECT d.name 项目名称,COUNT( a.id ) 新增bug数,a.type bug类型,b.realname bug提出者,c.name bug类型 FROM zt_bug a "
        "join zt_user b on a.openedBy = b.account join zt_module c ON a.module = c.id join zt_project d ON a.project = d.id "
        "WHERE a.project = {} AND DATE_FORMAT( a.openedDate, '%Y-%m-%d' )= CURRENT_DATE AND a.deleted = '0' GROUP BY a.openedBy;").format(mid)

        mydb = MyDbHelper("zentao")

        result = mydb.get_all(test_sql)
        test_list = []
        for item in result:
            if item['bug类型'] == "front":
                item['bug类型'] = "前端代码问题"
            elif item['bug类型'] == "codeerror":
                item['bug类型'] = "后端代码问题"
            elif item['bug类型'] == "history":
                item['bug类型'] = "历史遗留"
            elif item['bug类型'] == "install":
                item['bug类型'] = "安装部署"
            elif item['bug类型'] == "others":
                item['bug类型'] = "其他"
            elif item['bug类型'] == "designdefect":
                item['bug类型'] = "需求文档"
            elif item['bug类型'] == "security":
                item['bug类型'] = "安全问题"
            elif item['bug类型'] == "user":
                item['bug类型'] = "运营反馈"
            elif item['bug类型'] == "automation":
                item['bug类型'] = "测试脚本"

            test_list.append(item)
        a = dingRobot('test')
        title = ("当天新增的bug数量:\n")
        content = str(test_list)
        a.markdown(title, content)