Add README, rename tool to match repo, add .gitignore.

This commit is contained in:
Jonathan Bernard 2021-04-02 13:48:27 -05:00
parent dfd80ccf6a
commit ded8ca4b0c
6 changed files with 66 additions and 6 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
*.sw?
*.csv
*.json
jira_analysis
postgres.container.id

55
README.md Normal file
View File

@ -0,0 +1,55 @@
Script to extract data from JIRA and pull it into a postgres DB for analysis.
## Setup
1. Install [docker][docker-desktop]
2. [Generate an API token for your JIRA user.][jira-api-key]
3. Pull the database container:
```sh
make createdb
```
Feel free to edit the Makefile to view or change the default
username/password combination.
4. Build the tool:
```sh
nimble build
```
## Usage
- Start the database container:
```sh
make startdb
```
- Pull issues from your JIRA instance into the DB:
```sh
./jira_analysis api-sync <jira-base-url> <username> <api-token>
```
- Connect to the database for analysis:
```sh
make connect
```
## Convenient PostgreSQL commands
From within a `psql` session:
- Export tables to CSV:
```psql
\copy features TO features-export.csv DELIMITER ',' CSV HEADER;
\copy issues TO issues-export.csv DELIMITER ',' CSV HEADER;
\copy change_logs TO changelog-export.csv DELIMITER ',' CSV HEADER;
```
[docker-desktop]: https://www.docker.com/products/docker-desktop
[jira-api-key]: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

View File

@ -5,7 +5,7 @@ author = "Jonathan Bernard"
description = "A new awesome nimble package" description = "A new awesome nimble package"
license = "MIT" license = "MIT"
srcDir = "src/nim" srcDir = "src/nim"
bin = @["tm_pm"] bin = @["jira_analysis"]
# Dependencies # Dependencies

View File

@ -1,6 +1,6 @@
import csvtools, docopt, fiber_orm, db_postgres, sequtils, sets, strutils import csvtools, docopt, fiber_orm, db_postgres, sequtils, sets, strutils
import ./tm_pmpkg/jira_api import ./jira_analysispkg/jira_api
type type
Feature* = object Feature* = object
@ -27,11 +27,11 @@ when isMainModule:
let doc = """ let doc = """
Usage: Usage:
tm_pm import-csv <import-file> jira_analysis import-csv <import-file>
tm_pm api-sync <username> <api-key> jira_analysis api-sync <url-base> <username> <api-key>
""" """
let args = docopt(doc, version = "0.1.0") let args = docopt(doc, version = "0.2.0")
let db = connect("host=localhost port=5500 dbname=tegra118 user=postgres password=password") let db = connect("host=localhost port=5500 dbname=tegra118 user=postgres password=password")
if args["import-csv"]: if args["import-csv"]:
@ -58,7 +58,7 @@ Usage:
# db.createJiraIssue(issue); # db.createJiraIssue(issue);
if args["api-sync"]: if args["api-sync"]:
initJiraClient("https://tegra118.atlassian.net", $args["<username>"], $args["<api-key>"]) initJiraClient($args["<url-base>"], $args["<username>"], $args["<api-key>"])
let issuesAndChangelogs = searchIssues( let issuesAndChangelogs = searchIssues(
"project = \"UUP\" and (labels is empty or labels != \"Design&Reqs\") ORDER BY key ASC", "project = \"UUP\" and (labels is empty or labels != \"Design&Reqs\") ORDER BY key ASC",
includeChangelog = true includeChangelog = true