142 lines
3.4 KiB
Plaintext
142 lines
3.4 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
|
|
|
|
debug(f'get_sd_iterations.dspy:{ns=}')
|
|
if not ns.get('page'):
|
|
ns['page'] = 1
|
|
if not ns.get('sort'):
|
|
|
|
|
|
ns['sort'] = ["created_at desc"]
|
|
|
|
|
|
|
|
sql = '''select a.*, b.project_id_text, c.iteration_type_text, d.status_text
|
|
from (select * from sd_iterations where 1=1 [[filterstr]]) a left join (select id as project_id,
|
|
name as project_id_text from sd_projects where 1 = 1) b on a.project_id = b.project_id left join (select k as iteration_type,
|
|
v as iteration_type_text from appcodes_kv where parentid='sd_iteration_type') c on a.iteration_type = c.iteration_type left join (select k as status,
|
|
v as status_text from appcodes_kv where parentid='sd_iteration_status') d on a.status = d.status'''
|
|
|
|
filterjson = params_kw.get('data_filter')
|
|
if filterjson and isinstance(filterjson, str):
|
|
try:
|
|
filterjson = json.loads(filterjson)
|
|
except (json.JSONDecodeError, TypeError):
|
|
filterjson = None
|
|
fields_str=r'''[
|
|
{
|
|
"name": "id",
|
|
"title": "主键ID",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "project_id",
|
|
"title": "项目ID",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "iteration_name",
|
|
"title": "迭代名称",
|
|
"type": "str",
|
|
"length": 200,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "iteration_type",
|
|
"title": "迭代类型",
|
|
"type": "str",
|
|
"length": 20,
|
|
"nullable": "no",
|
|
"default": "'new_feature'"
|
|
},
|
|
{
|
|
"name": "scope",
|
|
"title": "迭代范围(JSON)",
|
|
"type": "text"
|
|
},
|
|
{
|
|
"name": "task_id",
|
|
"title": "关联Pipeline任务ID",
|
|
"type": "str",
|
|
"length": 32
|
|
},
|
|
{
|
|
"name": "status",
|
|
"title": "迭代状态",
|
|
"type": "str",
|
|
"length": 20,
|
|
"nullable": "no",
|
|
"default": "'planning'"
|
|
},
|
|
{
|
|
"name": "priority",
|
|
"title": "优先级",
|
|
"type": "int",
|
|
"nullable": "no",
|
|
"default": "5"
|
|
},
|
|
{
|
|
"name": "started_at",
|
|
"title": "开始时间",
|
|
"type": "timestamp"
|
|
},
|
|
{
|
|
"name": "completed_at",
|
|
"title": "完成时间",
|
|
"type": "timestamp"
|
|
},
|
|
{
|
|
"name": "created_by",
|
|
"title": "创建人",
|
|
"type": "str",
|
|
"length": 32
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"title": "创建时间",
|
|
"type": "timestamp",
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"title": "更新时间",
|
|
"type": "timestamp"
|
|
}
|
|
]'''
|
|
ori_fields = json.loads(fields_str)
|
|
if not filterjson:
|
|
fields = [ f['name'] for f in ori_fields ]
|
|
filterjson = default_filterjson(fields, ns)
|
|
|
|
filterdic = ns.copy()
|
|
filterdic['filterstr'] = ''
|
|
filterdic['userorgid'] = '${userorgid}$'
|
|
filterdic['userid'] = '${userid}$'
|
|
if filterjson:
|
|
dbf = DBFilter(filterjson)
|
|
conds = dbf.gen(ns)
|
|
if conds:
|
|
ns.update(dbf.consts)
|
|
conds = f' and {conds}'
|
|
filterdic['filterstr'] = conds
|
|
ac = ArgsConvert('[[', ']]')
|
|
vars = ac.findAllVariables(sql)
|
|
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
|
|
filterdic.update(NameSpace)
|
|
sql = ac.convert(sql, filterdic)
|
|
|
|
debug(f'{sql=}')
|
|
db = DBPools()
|
|
dbname = get_module_dbname('pipeline_sdlc')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
r = await sor.sqlPaging(sql, ns)
|
|
return r
|
|
return {
|
|
"total":0,
|
|
"rows":[]
|
|
} |