From ded8ca4b0cbdecd5b9c99f34a778ad880adf935d Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Fri, 2 Apr 2021 13:48:27 -0500 Subject: [PATCH] Add README, rename tool to match repo, add .gitignore. --- .gitignore | 5 ++ README.md | 55 +++++++++++++++++++ tm_pm.nimble => jira_analysis.nimble | 2 +- src/nim/{tm_pm.nim => jira_analysis.nim} | 10 ++-- .../{tm_pm.nim.cfg => jira_analysis.nim.cfg} | 0 .../jira_api.nim | 0 6 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 README.md rename tm_pm.nimble => jira_analysis.nimble (91%) rename src/nim/{tm_pm.nim => jira_analysis.nim} (91%) rename src/nim/{tm_pm.nim.cfg => jira_analysis.nim.cfg} (100%) rename src/nim/{tm_pmpkg => jira_analysispkg}/jira_api.nim (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bb5360e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.sw? +*.csv +*.json +jira_analysis +postgres.container.id diff --git a/README.md b/README.md new file mode 100644 index 0000000..b2d9570 --- /dev/null +++ b/README.md @@ -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 + ``` + +- 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/ diff --git a/tm_pm.nimble b/jira_analysis.nimble similarity index 91% rename from tm_pm.nimble rename to jira_analysis.nimble index aa32b90..3d1680c 100644 --- a/tm_pm.nimble +++ b/jira_analysis.nimble @@ -5,7 +5,7 @@ author = "Jonathan Bernard" description = "A new awesome nimble package" license = "MIT" srcDir = "src/nim" -bin = @["tm_pm"] +bin = @["jira_analysis"] # Dependencies diff --git a/src/nim/tm_pm.nim b/src/nim/jira_analysis.nim similarity index 91% rename from src/nim/tm_pm.nim rename to src/nim/jira_analysis.nim index 9abbeff..7000961 100644 --- a/src/nim/tm_pm.nim +++ b/src/nim/jira_analysis.nim @@ -1,6 +1,6 @@ import csvtools, docopt, fiber_orm, db_postgres, sequtils, sets, strutils -import ./tm_pmpkg/jira_api +import ./jira_analysispkg/jira_api type Feature* = object @@ -27,11 +27,11 @@ when isMainModule: let doc = """ Usage: - tm_pm import-csv - tm_pm api-sync + jira_analysis import-csv + jira_analysis api-sync """ - 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") if args["import-csv"]: @@ -58,7 +58,7 @@ Usage: # db.createJiraIssue(issue); if args["api-sync"]: - initJiraClient("https://tegra118.atlassian.net", $args[""], $args[""]) + initJiraClient($args[""], $args[""], $args[""]) let issuesAndChangelogs = searchIssues( "project = \"UUP\" and (labels is empty or labels != \"Design&Reqs\") ORDER BY key ASC", includeChangelog = true diff --git a/src/nim/tm_pm.nim.cfg b/src/nim/jira_analysis.nim.cfg similarity index 100% rename from src/nim/tm_pm.nim.cfg rename to src/nim/jira_analysis.nim.cfg diff --git a/src/nim/tm_pmpkg/jira_api.nim b/src/nim/jira_analysispkg/jira_api.nim similarity index 100% rename from src/nim/tm_pmpkg/jira_api.nim rename to src/nim/jira_analysispkg/jira_api.nim