Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/samples/work_item_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import datetime
import logging

from vsts.work_item_tracking.v4_1.models.wiql import Wiql

from samples import resource
from utils import emit

Expand Down Expand Up @@ -48,3 +50,29 @@ def get_work_items_as_of(context):
emit("(work item {0} omitted by server)".format(id_))

return work_items


@resource('wiql_query')
def wiql_query(context):
wit_client = context.connection.get_client(
"vsts.work_item_tracking.v4_1.work_item_tracking_client.WorkItemTrackingClient")

wiql = Wiql(query="""
select [System.Id],
[System.WorkItemType],
[System.Title],
[System.State],
[System.AreaPath],
[System.IterationPath],
[System.Tags]
from WorkItems
where [System.TeamProject] = @project
order by [System.ChangedDate] desc""")

wiql_result = wit_client.query_by_wiql(wiql)

emit("Results: {0}".format(len(wiql_result.work_items)))
for work_item in wiql_result.work_items:
emit("{0} {1}: {2}".format(work_item.fields['System.WorkItemType'],
work_item.id,
work_item.fields['System.Title']))