美文网首页
充分利用phabricator的api接口

充分利用phabricator的api接口

作者: 杨闯 | 来源:发表于2020-03-09 21:24 被阅读0次

现在许多人都在用phabricator,那么在用phabricator的同时,有没有想过对每一阶段的任务进行整理。明确每个人这一阶段的任务及任务种类个数。
相关接口可在conduit中进行查看,在这里我将描述一部分接口

接口一、通过父任务获取子任务

地址:/api/maniphest.info
传递参数:(post)

api.token:apitoken
task_id:任务号

返回结果

phids = text["result"]["dependsOnTaskPHIDs"]
for index in range(len(phids)):
    data["phids["+str(index)+"]"] = phids[index]

这里,phids就是获取到的每个子任务的任务号

接口二、通过任务号获取到对应的任务详情

通过上一个接口获取到的data数据加上api.token作为post数据请求api/maniphest.info,获取到每个任务的任务详情
数据请求

def query_maniphest(self, phid):
    params = {"api.token": self.token, 'phids[0]': phid}
    return self.http_get("api/maniphest.query", params)

返回结果

result = oneText["result"]

userPhid = {"api.token": token}
projectPhid = {"api.token": token}

for value in result.values():
    ownerPHID = value["ownerPHID"] #成员
    projectPHIDs = value["projectPHIDs"] #标签
    if ownerPHID not in userPhid.values() :
        userPhid["phids["+str(len(userPhid))+"]"] = ownerPHID
    for projectPHID in projectPHIDs:
        if projectPHID not in projectPhid.values() :
            projectPhid["phids["+str(len(projectPhid))+"]"] = projectPHID

接口三、通过ownerPHID获取用户姓名

def get_user_name(userPhid):
    oneR = requests.post("***/api/user.query", userPhid)
    oneText = json.loads(oneR.text)
    result = oneText["result"]
    data = []
    for dic in result:
        use = User()
        use.phid = dic["phid"]
        use.name = dic["realName"]
        data.append(use)
    return data

接口四、通过projectPHIDs获取标签描述

def get_project_info(phids):
    response = requests.post("***/api/project.query", phids)
    oneText = json.loads(response.text)
    result = oneText["result"]["data"]
    data = {}
    for (key,value) in result.items():
        name = value["name"]
        phid = key
        data[key] = name
    return data

这样,你想进行怎样的统计就看你自己的需求了

相关文章

网友评论

      本文标题:充分利用phabricator的api接口

      本文链接:https://www.haomeiwen.com/subject/cyumdhtx.html