@@ -112,28 +112,8 @@ def get_work_attributes(self):
112112 """
113113 return { x ["key" ]: x for x in self ._list ("/work-attributes" ) }
114114
115-
116- def get_worklogs (self , date_from , date_to , user = None , add_work_attributes = False ):
117- """
118- Returns worklogs inside ```date_from``` and ```date_to```,
119- for particular ```user```, adding work attributes if ```add_work_attributes```.
120- """
121-
122- work_attributes = None
123- date_from = self ._resolve_date (date_from ).isoformat ()
124- date_to = self ._resolve_date (date_to ).isoformat ()
125- url = "/worklogs"
126- if user is not None :
127- url += "/user/{}" .format (user )
128- params = { "from" : date_from , "to" : date_to , "limit" : self .MAX_RESULTS }
129- l = self ._list (url , ** params )
130-
131- # restructure workattributes
132-
133- if not self .work_attributes :
134- self .work_attributes = self .get_work_attributes ()
135-
136- for worklog in l :
115+ def _process_worklogs (self , worklogs ):
116+ for worklog in worklogs :
137117 attributes = (worklog .get ("attributes" ) or {}).get ("values" ) or {}
138118 resolved_attributes = {}
139119
@@ -145,6 +125,39 @@ def get_worklogs(self, date_from, date_to, user=None, add_work_attributes=False)
145125 worklog ["attributes" ] = resolved_attributes
146126 yield worklog
147127
128+ def get_all_worklogs (self , date_from , date_to ):
129+ date_from = self ._resolve_date (date_from ).isoformat ()
130+ date_to = self ._resolve_date (date_to ).isoformat ()
131+ url = f"/worklogs"
132+ params = { "from" : date_from , "to" : date_to , "limit" : self .MAX_RESULTS }
133+ l = self ._list (url , ** params )
134+ return self ._process_worklogs (l )
135+
136+ def get_user_worklogs (self , date_from , date_to , userid ):
137+ """
138+ Returns worklogs inside ```date_from``` and ```date_to```,
139+ for particular ```user```.
140+ """
141+
142+ date_from = self ._resolve_date (date_from ).isoformat ()
143+ date_to = self ._resolve_date (date_to ).isoformat ()
144+ url = f"/worklogs/user/{ userid } "
145+ params = { "from" : date_from , "to" : date_to , "limit" : self .MAX_RESULTS }
146+ l = self ._list (url , ** params )
147+ return self ._process_worklogs (l )
148+
149+ def get_team_worklogs (self , date_from , date_to , teamid ):
150+ """
151+ Returns worklogs inside ```date_from``` and ```date_to```,
152+ for particular ```team```.
153+ """
154+
155+ date_from = self ._resolve_date (date_from ).isoformat ()
156+ date_to = self ._resolve_date (date_to ).isoformat ()
157+ url = f"/worklogs/team/{ teamid } "
158+ params = { "from" : date_from , "to" : date_to , "limit" : self .MAX_RESULTS }
159+ l = self ._list (url , ** params )
160+ return self ._process_worklogs (l )
148161
149162 def get_user_schedule (self , date_from , date_to , user = None ):
150163 """
@@ -157,4 +170,4 @@ def get_user_schedule(self, date_from, date_to, user=None):
157170 if user is not None :
158171 url += "/{}" .format (user )
159172 params = { "from" : date_from , "to" : date_to , "limit" : self .MAX_RESULTS }
160- return list (self ._list (url , ** params ))
173+ return list (self ._list (url , ** params ))
0 commit comments