Library to calculate various metrics of software development process
Project description
sd-metrics-lib
Python library for calculation of various metrics related to software development process. Provides user velocity calculation based on data from Jira. Metrics calculation classes are using interfaces, so it could be easily extended with another data providers, like Trello, Asana etc. from application code.
Implementation notes
General architecture is simple and has 2 main parts:
- calculators package:
- UserVelocityCalculator class calculates user velocity or developer performance in other words. Requires IssueProvider, StoryPointExtractor and WorklogExtractor for calculation.
- GeneralizedTeamVelocityCalculator class calculates team generalized velocity. Requires IssueProvider, StoryPointExtractor and IssueTotalSpentTimeExtractor for calculation.
- data_providers package:
- IssueProvider interface designed to provide issues/tickets for calculators.
- JiraIssueProvider implementation class, which fetches issues from Jira by JQL using jira client
from atlassian-python-api. Supports multithreading.
- CachingJiraIssueProvider wraps JiraIssueProvider with caching.
- ProxyIssueProvider wrapper for issues fetched from another data providers.
- JiraIssueProvider implementation class, which fetches issues from Jira by JQL using jira client
from atlassian-python-api. Supports multithreading.
- StoryPointExtractor interface designed to extract "story points" from issue.
- JiraCustomFieldStoryPointExtractor implementation class, which extract value of custom field from Jira.
- JiraTShirtStoryPointExtractor implementation class, which extract value of custom field from Jira and maps string value into numbers.
- WorklogExtractor interface designed to extract amount of time users spent on ticket.
- JiraWorklogExtractor implementation class, which uses regular jira work log entries to define user spent time.
- JiraStatusChangeWorklogExtractor implementation class, which uses issue status change history log to define user spent time on issue.
- JiraResolutionTimeIssueTotalSpentTimeExtractor implementation class, which uses creation and resolution time to calculate total spent time on issue.
- ChainedWorklogExtractor implementation class, which allows "chain" WorklogExtractor to execute them one by one.
- WorkTimeExtractor interface designed to extract and calculate working time from period.
- SimpleWorkTimeExtractor Simple work time calculation. For more precision calculation you can use businesstimedelta.
- BoundarySimpleWorkTimeExtractor Uses SimpleWorkTimeExtractor to limit calculation time range. Useful for workload calculation in some period of time, for example for "days without work" calculation.
- IssueProvider interface designed to provide issues/tickets for calculators.
Also library provides few util classes:
- JiraIssueSearchQueryBuilder builder for JQL queries.
- TimeRangeGenerator generator for time ranges. Useful for filtering by resolution date to calculate velocity for set of period of time.
Code examples
Calculate amount of tickets developer resolves per day based on Jira ticket status change history.
This code should work on any project and give at least some data for analysis.
from atlassian import Jira
from calculators import UserVelocityCalculator
from calculators.velocity_calculator import VelocityTimeUnit
from data_providers.jira.issue_provider import JiraIssueProvider
from data_providers.jira.worklog_extractor import JiraStatusChangeWorklogExtractor
from data_providers.story_point_extractor import ConstantStoryPointExtractor
JIRA_SERVER = 'server_url'
JIRA_LOGIN = 'login'
JIRA_PASS = 'password'
jira_client = Jira(JIRA_SERVER, JIRA_LOGIN, JIRA_PASS, cloud=True)
jql = " project in ('TBC') AND resolutiondate >= 2022-08-01 "
jql_issue_provider = JiraIssueProvider(jira_client, jql, expand=['changelog'])
story_point_extractor = ConstantStoryPointExtractor()
jira_worklog_extractor = JiraStatusChangeWorklogExtractor(['In Progress', 'In Development'])
velocity_calculator = UserVelocityCalculator(issue_provider=jql_issue_provider,
story_point_extractor=story_point_extractor,
worklog_extractor=jira_worklog_extractor)
velocity = velocity_calculator.calculate(velocity_time_unit=VelocityTimeUnit.DAY)
print(velocity)
Calculate amount of story points developer resolves per day based on Jira worklog.
This code will provide good enough dev performance metrics on projects, where worklog and story points are entered in Jira.
from atlassian import Jira
from calculators import UserVelocityCalculator
from calculators.velocity_calculator import VelocityTimeUnit
from data_providers.jira.issue_provider import JiraIssueProvider
from data_providers.jira.worklog_extractor import JiraWorklogExtractor
from data_providers.jira import JiraCustomFieldStoryPointExtractor
JIRA_SERVER = 'server_url'
JIRA_LOGIN = 'login'
JIRA_PASS = 'password'
jira_client = Jira(JIRA_SERVER, JIRA_LOGIN, JIRA_PASS, cloud=True)
jql = " project in ('TBC') AND resolutiondate >= 2022-08-01 "
jql_issue_provider = JiraIssueProvider(jira_client, jql)
story_point_extractor = JiraCustomFieldStoryPointExtractor('customfield_10010')
jira_worklog_extractor = JiraWorklogExtractor(jira_client)
velocity_calculator = UserVelocityCalculator(issue_provider=jql_issue_provider,
story_point_extractor=story_point_extractor,
worklog_extractor=jira_worklog_extractor)
velocity = velocity_calculator.calculate(velocity_time_unit=VelocityTimeUnit.DAY)
print(velocity)
Version history
1.2.1
- (Improvement) Add possibility to adjust init time
- (Bug Fix) Fix bug with wrong cache data fetching
- (Bug Fix) Fix bug in week time period end date resolving
1.2
- (Feature) Added BoundarySimpleWorkTimeExtractor
- (Improvement) Filter unneeded changelog items for better performance
- (Improvement) Add T-Shirt to story points mapping util class
- (Improvement) Add helper enums
- (Bug Fix) Fix bug with story points returned instead of spent time
- (Bug Fix) Fix bug with missing time for active status
- (Bug Fix) Fix bug with passing class instances in extractor
1.1.4
- (Improvement) Add multithreading support for JiraIssueProvider.
1.1.3
- (Feature) Add CachingJiraIssueProvider.
1.1.2
- (Improvement) Add story points getter for GeneralizedTeamVelocityCalculator.
1.1.1
- (Improvement) Execute data fetching in Jira velocity calculators only once.
- (Improvement) Add story points getter for Jira velocity calculators.
1.1
- (Feature) Add team velocity calculator.
- (Improvement) Add JQL filter for last modified data.
- (Bug Fix) Fix wrong user resolving in JiraStatusChangeWorklogExtractor.
- (Bug Fix) Fix resolving more time than spent period of time.
- (Bug Fix) Fix Jira filter query joins without AND.
1.0.3
- (Improvement) Add JiraIssueSearchQueryBuilder util class.
- (Improvement) Add TimeRangeGenerator util class.
- (Bug Fix) Fix filtering by status when no status list passed.
1.0.2
- (Bug Fix) Fix package import exception after installing from pypi.
1.0
- (Feature) Add user velocity calculator.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sd-metrics-lib-1.2.1.tar.gz
.
File metadata
- Download URL: sd-metrics-lib-1.2.1.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf1336578e077d234c85e71b1fde880691e9e3a30500432497d8a800efb542d8 |
|
MD5 | 3e03d1a3a3152e27d1e45446dcd0b488 |
|
BLAKE2b-256 | 8ba3c93d95b2a58fc7e5c925194ac2f3c652d2187ae612c11da6aa146ee3296e |
File details
Details for the file sd_metrics_lib-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: sd_metrics_lib-1.2.1-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00e41c614489bf4ca54fdc913ebc52d25d508d64595c0dd3d0f35676571aee4c |
|
MD5 | 8094b4352f3243e458847160538a7a5f |
|
BLAKE2b-256 | 04a01c8ce83f5a6886fe3d26d0eec3dcfe7c17e96c20d5a85f200b54a6bfe637 |