首页 文章

Visual Studio Online中的时间跟踪

提问于
浏览
11

有没有办法在Visual Studio Online中测量用例或任务所花费的时间?我想将所有内容保存在一个地方(Visual Studio Online就是这种情况)并从那里能够生成报告,例如每个用户的每月时间跟踪报告以及反映已经处理的实际时间的每日报告特定用例/任务与估计时间的关系 .

3 回答

  • 3

    当您创建链接到Backlog项目或Bug的任务时,剩余工作字段实际上是以小时为单位 . 因此,您可以将其设置为具有时间跟踪 .

    不幸的是,据我所知,没有办法设置任务完成后的实际时间 .

  • 5

    不,在VSO或TFS上没有办法开箱即用 . 这种方法不利于有效和 Value 交付 . 事实上,研究表明,为客户提供 Value 可能是有害的 .

    虽然有第三方工具插入VSO并提供此功能,但我会建议采用不同的方法 .

    对课程粒度任务进行单独的时间跟踪 . 专注于计费而非时间跟踪 . 我想知道要收费的客户或项目以及capex vs opex ...除此之外,数据几乎没有 Value . 我使用Freshbooks并成功使用了Harvest .

    更新:如果您是咨询公司,您显然需要跟踪计费时间 . 这应该在与TFS不同的系统中完成 .

  • 1

    我过去使用过Jira,喜欢记录工作时间的方式 .

    我们使用注释列表在VSTS中创建了一种解决方法 . 它不优雅,但它的工作原理 . 一个在评论中添加一个数值,并计算为工作小时数 . 你可以使用正则表达式使这更复杂,但我附上的代码假设有一个浮点数或整数 .

    URL_PREFACE =  "https://yourproject.visualstudio.com/defaultcollection/"
    
    def getTicketComments(ticketID):
        """ Gets a list of the comments (in order from oldest to newest) for a given ticket """
    
        url = URL_PREFACE + "_apis/wit/workitems/" + str(ticketID) + "/comments?api-version=3.0-preview&order=asc"
        jsonDict = readURL(url)
    
        return jsonDict["comments"]
    

    然后我们总结我们找到的值:

    def getHoursSum(ticketID):
        """ For the given ticket, gets their comments, and calculates the hours
        """
        commentList = getTicketComments(ticketID)
        hourSum = 0
        for comment in commentList:
            try:
                hourSum += float(comment["text"]) # Will break if it's not a number
            except:
                pass
    
    return hourSum
    

    最后,我们存储 CompletedWork 字段中的工作小时数:

    def updateHours(ticketID, completedHours):
    
        headers = {"Content-Type": "application/json-patch+json"}
    
        url = URL_PREFACE + "_apis/wit/workitems/" + str(ticketID) + "?api-version=1.0"
    
        body = """[
            {
                "op": "replace",
                "path": "/fields/Microsoft.VSTS.Scheduling.CompletedWork",
                "value": """ + str(completedHours) + """
            }
        ]"""
    
        username = 'username'  # Doesn't matter
        password = TOKEN
    
        # TO GET TOKEN:
        #   Log into https://yourproject.visualstudio.com/
        #   Click on your name -> My Profile
        #   In the left-hand sidebar, click on "Security"
        #   Under "Personal Accesss Tokens," click "Add"
        #   Under "Description" give your token a name (doesn't matter)
        #   Choose an expiration for your token (recommend: 1 yr)
        #   "Authorized Scopes" = "All Scopes"
        #   Click "Save"
        #   Copy the token it gives you into token field below (paste between quotes)
    
        session = requests.Session()
        request = requests.Request(method="PATCH", headers=headers, auth=(username, password),
                                   url=url,  data=body)
        prepped = request.prepare()
        response = session.send(prepped)
    
        return response
    

    (我只是复制并粘贴了一些简化的代码 - 你需要整合它 . )

    代码由我最优秀的同事@Elliptica撰写 .

相关问题