Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evref-bl/jira-pharo-api
Analyze data from Jira
https://github.com/evref-bl/jira-pharo-api
Last synced: 28 days ago
JSON representation
Analyze data from Jira
- Host: GitHub
- URL: https://github.com/evref-bl/jira-pharo-api
- Owner: Evref-BL
- Created: 2023-09-25T07:19:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-23T07:17:32.000Z (2 months ago)
- Last Synced: 2024-11-17T08:44:10.782Z (about 1 month ago)
- Language: Smalltalk
- Homepage:
- Size: 60.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Jira-Pharo-API
[![Continuous](https://github.com/Evref-BL/Jira-Pharo-API/actions/workflows/continuous.yml/badge.svg)](https://github.com/Evref-BL/Jira-Pharo-API/actions/workflows/continuous.yml)
[![Coverage Status](https://coveralls.io/repos/github/Evref-BL/Jira-Pharo-API/badge.svg?branch=main)](https://coveralls.io/github/Evref-BL/Jira-Pharo-API?branch=main)This is a client for the [Jira REST API](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#about).
## Installation
```st
Metacello new
githubUser: 'Evref-BL' project: 'Jira-Pharo-API' commitish: 'main' path: 'src';
baseline: 'JiraPharoAPI';
load
```## Connect the API to Jira
The first step before querying is to connect to the Jira API.
On the official atlassian Jira, perform the following script:
```smalltalk
jpAPI := JiraPharoAPI new.
jpAPI endpoint: ''.
jpAPI basePath: '/rest/api/latest/'.
jpAPI beHttps.jpAPI user: ''.
jpAPI apiToken: ''.
```If you still have a olf self-hosted Jira, you might want to use the following script.
```smalltalk
jpAPI := JiraPharoAPI new.
jpAPI endpoint: ''.
jpAPI basePath: '/rest/api/latest/'.
jpAPI beHttps.
jpAPI bearerToken: ''.
```## Example with Moose
This project comes with an integration to the Moose environment.
It comes with a specific importer for this purpose that simply the data analysis.### Import the issues assigned to a user in moose
```st
jpImporter := JiraPharoImporter new
model: JPModel new;
api: jpAPI;
yourself.jpImporter importAllIssuesOf: ''.
jpImporter model
```## Example API only
### Get information about one issue
```smalltalk
jpAPI issue: ''.
```### Search issue API
We define the API to search issues using the [JQL](https://confluence.atlassian.com/x/egORLQ) query language of Atlassian.
We propose here some example but you can do a lot more.#### Get all issues of a project after a date
```smalltalk
issues := OrderedCollection new.
tmp := jpAPI searchIssueWithExpand: nil fields: {'*navigable' . 'created'} fieldsByKeys: nil jql: 'project = and created > ''2023-01-01''' maxResults: 100 startAt: 0.issues addAll: tmp issues.
[tmp issues isNotEmpty ] whileTrue: [tmp := jpAPI searchIssueWithExpand: nil fields: {'*navigable' . 'created'} fieldsByKeys: nil jql: 'project = and created > ''2023-01-01''' maxResults: 100 startAt: issues size.
issues addAll: tmp issues.
].allJiraIssues := issues
```#### Search all issues assigned to a user
```smalltalk
issues := OrderedCollection new.
tmp := jpAPI searchIssueWithExpand: nil fields: {'*navigable' . 'created'} fieldsByKeys: nil jql: 'assignee = "[email protected]"' maxResults: 100 startAt: 0.issues addAll: tmp issues.
[tmp issues isNotEmpty ] whileTrue: [tmp := jpAPI searchIssueWithExpand: nil fields: {'*navigable' . 'created'} fieldsByKeys: nil jql: 'assignee = "[email protected]"' maxResults: 100 startAt: issues size.
issues addAll: tmp issues.
].allJiraIssues := issues
```#### Compute average time spent on jira issues by month for a user
```smalltalk
user := ''.
jqlQuery := String streamContents: [ :stream |
stream << 'assignee = "'.
stream << user.
stream << '"'
].issues := OrderedCollection new.
tmp := jpAPI searchIssueWithExpand: nil fields: {'*all'} fieldsByKeys: nil jql: jqlQuery maxResults: 100 startAt: 0.issues addAll: tmp issues.
[tmp issues isNotEmpty ] whileTrue: [tmp := jpAPI searchIssueWithExpand: nil fields: {'*all'} fieldsByKeys: nil jql: jqlQuery maxResults: 100 startAt: issues size.
issues addAll: tmp issues.
].allJiraIssues := issues.
jiraWithTime := allJiraIssues reject: [ :jiraIssue | jiraIssue timespent isNil ].
grouped := jiraWithTime groupedBy: [ :jiraIssue | jiraIssue created month ].
computedMean := OrderedDictionary new.
grouped keysDo: [ :key | computedMean at: key put: ((grouped at: key) sum: #timespent) / (grouped at: key) size ]."To get a visualization"
c := RSCompositeChart new.
c add: (RSBarPlot new y: (computedMean values collect: #asSeconds)).
c horizontalTick fromNames: computedMean orderedKeys;
useDiagonalLabel.
c verticalTick labelConversion: [ :v | v seconds ].
c xlabel: 'Month'.
c ylabel: 'Time spent'.
c title: 'Mean time spend by dev on jira issue'.
c
```Another option is to assign a jira ticket to the first month work has been log on it
```smalltalk
jiraWithTime := allJiraIssues reject: [ :jiraIssue | jiraIssue timespent isNil ].
grouped := jiraWithTime groupedBy: [ :jiraIssue | jiraIssue worklogs first created asDate month ].
sortedGrouped := (grouped associations asOrderedCollection sort: [:a :b | a key < b key]) asOrderedDictionary .
computedMean := OrderedDictionary new.
sortedGrouped keysDo: [ :key | computedMean at: key put: ((grouped at: key) sum: #timespent) / (grouped at: key) size ].c := RSCompositeChart new.
c add: (RSBarPlot new y: (computedMean values collect: #asSeconds)).
c horizontalTick fromNames: computedMean orderedKeys;
useDiagonalLabel.
c verticalTick labelConversion: [ :v | v seconds ].
c xlabel: 'Month'.
c ylabel: 'Time spent'.
c title: 'Mean time spend by dev on jira issue'.
c
```