def to_youtrack_workitem(trac_workitem): workitem = youtrack.WorkItem() workitem.date = str(trac_workitem.time) workitem.duration = str(int(trac_workitem.duration) / 60) workitem.authorLogin = trac_workitem.author workitem.description = trac_workitem.comment return workitem
def getWorkItems(self, issue_id): try: response, content = self._req('GET', '/issue/%s/timetracking/workitem' % urlquote(issue_id)) xml = minidom.parseString(content) return [youtrack.WorkItem(e, self) for e in xml.documentElement.childNodes if e.nodeType == Node.ELEMENT_NODE] except youtrack.YouTrackException, e: print "Can't get work items.", str(e) return []
def _add_work_items(self, issue): import_data = [] work_items = self._source.get_time_entries(issue.id) for t in sorted(work_items, key=lambda t: t.spent_on): work_item = youtrack.WorkItem() work_item.authorLogin = self._create_user(t.user).login work_item.date = str(to_unixtime(t.spent_on)) work_item.description = t.comments work_item.duration = int(float(t.hours) * 60) import_data.append(work_item) if import_data: self._target.importWorkItems(self._get_yt_issue_id(issue), import_data)