View on GitHub

Usage JIRA API with Python

from jira import JIRA
user = "jira_login"
password = "jira_password"
jira = JIRA(url, basic_auth=(user, password))

We can calcualte active tasks total time, which were changed today (for last 8 hours):

updated_today_issues = jira.search_issues(
	'assignee=%s and resolution=%s and updated %s and status in %s order by %s DESC',
	('currentUser()', 'Unresolved', '>= -8h',
	 '(Open, "In Progress", Reopened,"Under review")', 'updatedDate'))
sum([issue.fields.timespent for issue in updated_today_issues])

It’s not suitable: resulting value summarize all time logged for active tasks from the task creation date. Somebody can changed some field of the task, so it affects to ‘update time’ field.

And how can we take total time for all tasks, logged only today ?

We need take all issues which have been updated today and find total time in worklogs I’ve updated:

logged_today_issues = jira.search_issues(
		'assignee=%s and updated %s order by %s DESC',
		('currentUser()', '>= -8h', 'updatedDate'))

for i in logged_today_issues:
	issue_worklogs = i.fields.worklog.worklogs
	my_today_issue_worklogs = filter(
		lambda x: x.author.name == user and x.created >= time.today(),
			issue_worklogs)