Calculate work logged by a specific user across multiple Jira Cloud issues

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

Disclaimer

The below example of a Python code is provided on as-is basis. Further support may not be available. Use at your own discretion and always make sure you know what you are doing.

If you want to calculate work time logged by a specific user across multiple Jira Cloud issues, there is no existing native way to achieve this using JQL or Dashboard Gadgets.

Usecase

Multiple users were contributing to a single project and you want to calculate total time a specified user logged across selected issues.

Environment

This has been tested on Jira Cloud Premium.

Solution

You may use the code, published below to calculate time logged across multiple tickets by a specified user. Be sure to update it to your needs.

Prerequisites

  1. Installed Python and PIP:

    https://www.python.org/downloads/

  2. Installed requestsmodule:

    Run in Terminal: pip install requests

  3. Jira Cloud API token:

    Manage API tokens for your Atlassian account.

Input:

  • JQL - to filter issues, we want to calculate the work log time across.

  • Login email - email address of the API Key owner

  • API Key - of the user, who has access to all projects/issues, returned by the above JQL.

  • Search email - the email of the user, we calculating the logged time for.

Output:

  • Number of minutes logged by above specified user across issues, filtered out by the above mentioned JQL.

Example:

Input:

1 2 3 4 JQL_QUERY = 'worklogDate >= "2024-01-01" and worklogDate <="2024-06-30"' LOGIN_USER_EMAIL = 'admin@domain.com' API_TOKEN = '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' SEARCH_USER_EMAIL = 'user@domain.com'

Output:

Time logged is 787m

Code

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 import requests from requests.auth import HTTPBasicAuth JQL_QUERY = 'worklogDate >= "2024-01-01" and worklogDate <="2024-06-30"' LOGIN_USER_EMAIL = 'admin@domain.com' # email of the API token owner API_TOKEN = 'paste_token_here' SEARCH_USER_EMAIL = 'user@domain.com' # email of the user we are counting time of JIRA_URL = 'https://your-domain.atlassian.net' SEARCH_URL = f'{JIRA_URL}/rest/api/3/search' WORKLOG_URL = f'{JIRA_URL}/rest/api/3/issue' HEADERS = {    "Accept": "application/json", "Content-Type": "application/json" } PARAMS = { 'jql': JQL_QUERY, 'fields': 'key', 'maxResults': 1000 } def fetch_issue_keys(): issue_keys = [] start_at = 0 while True: response = requests.get(SEARCH_URL, headers=HEADERS, params={**PARAMS, 'startAt': start_at}, auth=HTTPBasicAuth(LOGIN_USER_EMAIL, API_TOKEN)) response.raise_for_status() data = response.json() issues = data.get('issues', []) if not issues: break issue_keys.extend(issue['key'] for issue in issues) start_at += len(issues) if start_at >= data['total']: break return issue_keys def convert_time_to_minutes(time_str): hours = sum(int(part[:-1]) * 60 for part in time_str.split() if 'h' in part) minutes = sum(int(part[:-1]) for part in time_str.split() if 'm' in part) return hours + minutes def fetch_total_logged_time(issue_keys): total_time = 0 for issue_key in issue_keys: response = requests.get(f'{WORKLOG_URL}/{issue_key}/worklog', headers=HEADERS, auth=HTTPBasicAuth(LOGIN_USER_EMAIL, API_TOKEN)) response.raise_for_status() worklogs = response.json()['worklogs'] for worklog in worklogs: if worklog['author']['emailAddress'] == SEARCH_USER_EMAIL: total_time += convert_time_to_minutes(worklog['timeSpent']) return total_time if __name__ == '__main__': issue_keys = fetch_issue_keys() total_time = fetch_total_logged_time(issue_keys) print(f'\nTime logged is {total_time}m\n')
Updated on April 15, 2025

Still need help?

The Atlassian Community is here for you.