jira相信大多数开发、测试工程师都在知道,功能测试、集成测试等环节少不了它,但是一个个录入bug并不适宜所有场景。比如做数据爬虫,比如代码质量走查,就不好人为直接干涉,于是我决心好好看一下jira,把atlassian-jira
反编译看看他的代码,多的吓人,老技术,真心不想看下去了,于是只好从数据库着手。
全量的数据有这么多
并不是所有数据都有数据,于是我将没有数据的表,一个个删除。当然这些表的数据,是我们使用了5年的jira数据库,删掉之后,从原来186,降到了96张
分析表结构后,编写脚本写入数据库
import datetime
import json
import time
import pandas as pd
from sqlalchemy.engine import create_engine
from . import settings
ENGINE = create_engine('mysql+mysqldb://{}:{}@{}:3306/{}'.format(settings.MYSQL_USER, settings.MYSQL_PASSWD,
settings.MYSQL_HOST, settings.MYSQL_DBNAME),
connect_args={
'charset': 'utf8'}, pool_size=settings.MYSQL_POOL_SIZE)
class ProjectService:
'''
项目表
'''
def __init__(self):
pass
def select(self,pkey):
if not pkey:
raise Exception("pkey不能为空")
sql = "select ID, pname from project where pkey='{}'".format(pkey)
df = pd.read_sql(sql,ENGINE)
records = json.loads(df.to_json(orient='records'))
if records:
return records[0]
else:
raise Exception("没有找到对应的项目")
class OsWfentryService:
'''
osworkflow入口
'''
def __init__(self):
self.osCurrentstepService = OsCurrentstepService()
def gen_max_id(self):
sql = "select MAX(ID) ID from os_wfentry"
df = pd.read_sql(sql,ENGINE)
results = json.loads(df.to_json(orient='records'))
if len(results) == 0:
raise Exception("jira系统异常")
return results[0]['ID'] +1
def start_workflow(self,):
os_wfentry = {
'NAME':'jira', 'STATE':1}
os_wfentry['ID'] = self.gen_max_id()
df = pd.DataFrame([os_wfentry])
df.to_sql('os_wfentry', ENGINE, if_exists='append', index=False)
print('工作流产生成功')
self.osCurrentstepService.gen_current_step(os_wfentry['ID'])
return os_wfentry['ID']
class OsCurrentstepService:
'''
工作流当前步骤
'''
def __init__(self):
pass
def gen_max_id(self):
sql = "select MAX(ID) ID from os_currentstep"
df = pd.read_sql(sql,ENGINE)
results = json.loads(df.to_json(orient='records'))
if len(results) == 0:
raise Exception("jira系统异常")
return results[0]['ID'] +1
def gen_current_step(self,entry_id):
os_currentstep = {
'STEP_ID':1,'ACTION_ID':0,'STATUS':'Open'