Skip to content

Commit

Permalink
Merge pull request #183 from the-working-rene/main
Browse files Browse the repository at this point in the history
add global queryWorkitems method
  • Loading branch information
jesper-raemaekers authored Nov 13, 2024
2 parents 46cf29c + 818be9e commit 7376aac
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion polarion/polarion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from zeep.transports import Transport

from .project import Project
from .workitem import Workitem
import logging
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -120,7 +121,7 @@ def _createSession(self):
else:
raise Exception(
'Cannot login because WSDL has no SessionWebService')

def get_client(self,service,plugins=[]):
client = None

Expand Down Expand Up @@ -246,6 +247,25 @@ def getProject(self, project_id):
"""
return Project(self, project_id)

def queryWorkitems(self, query: str, sort: str):
"""Get List of workitems based on a query.
Query is global and not project specific, so it will return workitems from all projects. Use with caution.
Uses the Polarion query language. Documented as 'Advanced Work Item querying' in the Polarion documentation.
:param query: The query.
:param sort: The field to be used for sorting.
:return: The workitems matching the query
:rtype: Workitem[]
"""
service = self.getService("Tracker")
results = service.queryWorkItems(query, sort, fields=["project.id"])
workitems = []
for result in results:
project = self.getProject(result.project.id)
workitems.append(Workitem(self, project, uri=result.uri))
return workitems


def downloadFromSvn(self, url):

if self.svn_repo_url is not None:
Expand Down

0 comments on commit 7376aac

Please sign in to comment.