有没有一种方法可以在Visual Studio Online上测量用例或任务所花费的时间?我想把所有东西都放在一个地方(Visual Studio Online将是该情况),然后能够从那里生成报告,例如每个用户的月度时间跟踪报告和每日报告,反映实际工作在特定用例/任务上所耗费的时间与估计时间的差异。
有没有一种方法可以在Visual Studio Online上测量用例或任务所花费的时间?我想把所有东西都放在一个地方(Visual Studio Online将是该情况),然后能够从那里生成报告,例如每个用户的月度时间跟踪报告和每日报告,反映实际工作在特定用例/任务上所耗费的时间与估计时间的差异。
我以前使用过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编写的。