Skip to content

Commit

Permalink
Merge pull request #2 from dataiku/feature/read-issues-comments
Browse files Browse the repository at this point in the history
Feature/read issues comments
  • Loading branch information
alexbourret authored Sep 4, 2024
2 parents 60d9dcb + 7ead09f commit 397e53c
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## [Version 1.0.1](https://github.com/dataiku/dss-plugin-jira/releases/tag/v1.0.1) - Feature release - 2024-08-15

- Add option to retrieve comments on issues
45 changes: 30 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,58 @@ archive_file_name="dss-plugin-${plugin_id}-${plugin_version}.zip"
remote_url=`git config --get remote.origin.url`
last_commit_id=`git rev-parse HEAD`

.DEFAULT_GOAL := plugin

plugin:
plugin: dist-clean
@echo "[START] Archiving plugin to dist/ folder..."
@cat plugin.json | json_pp > /dev/null
@rm -rf dist
@mkdir dist
@echo "{\"remote_url\":\"${remote_url}\",\"last_commit_id\":\"${last_commit_id}\"}" > release_info.json
@git archive -v -9 --format zip -o dist/${archive_file_name} HEAD
@if [[ -d tests ]]; then \
zip --delete dist/${archive_file_name} "tests/*"; \
fi
@zip -u dist/${archive_file_name} release_info.json
@rm release_info.json
@echo "[SUCCESS] Archiving plugin to dist/ folder: Done!"

dev: dist-clean
@echo "[START] Archiving plugin to dist/ folder... (dev mode)"
@cat plugin.json | json_pp > /dev/null
@mkdir dist
@zip -v -9 dist/${archive_file_name} -r . --exclude "tests/*" "env/*" ".git/*" ".pytest_cache/*" ".idea/*" "dist/*"
@echo "[SUCCESS] Archiving plugin to dist/ folder: Done!"

unit-tests:
@echo "[START] Running unit tests..."
@echo "Running unit tests..."
@( \
PYTHON_VERSION=`python3 -V 2>&1 | sed 's/[^0-9]*//g' | cut -c 1,2`; \
PYTHON_VERSION_IS_CORRECT=`cat code-env/python/desc.json | python3 -c "import sys, json; print(str($$PYTHON_VERSION) in [x[-2:] for x in json.load(sys.stdin)['acceptedPythonInterpreters']]);"`; \
if [ ! $$PYTHON_VERSION_IS_CORRECT ]; then echo "Python version $$PYTHON_VERSION is not in acceptedPythonInterpreters"; exit 1; fi; \
PYTHON_VERSION=`python3 -c "import sys; print('PYTHON{}{}'.format(sys.version_info.major, sys.version_info.minor))"`; \
PYTHON_VERSION_IS_CORRECT=`cat code-env/python/desc.json | python3 -c "import sys, json; print('$$PYTHON_VERSION' in json.load(sys.stdin)['acceptedPythonInterpreters']);"`; \
if [ $$PYTHON_VERSION_IS_CORRECT == "False" ]; then echo "Python version $$PYTHON_VERSION is not in acceptedPythonInterpreters"; exit 1; else echo "Python version $$PYTHON_VERSION is in acceptedPythonInterpreters"; fi; \
)
@( \
rm -rf ./env/; \
python3 -m venv env/; \
source env/bin/activate; \
pip3 install --upgrade pip; \
pip install --no-cache-dir -r tests/python/requirements.txt; \
pip install --upgrade pip;\
pip install --no-cache-dir -r tests/python/unit/requirements.txt; \
pip install --no-cache-dir -r code-env/python/spec/requirements.txt; \
export PYTHONPATH="$(PYTHONPATH):$(PWD)/python-lib"; \
pytest -o junit_family=xunit2 --junitxml=unit.xml tests/python/unit || true; \
deactivate; \
python3 -m pytest tests/python/unit --alluredir=tests/allure_report || ret=$$?; exit $$ret \
)
@echo "[SUCCESS] Running unit tests: Done!"

integration-tests:
@echo "[START] Running integration tests..."
# TODO add integration tests
@echo "[SUCCESS] Running integration tests: Done!"
@echo "Running integration tests..."
@( \
rm -rf ./env/; \
python3 -m venv env/; \
source env/bin/activate; \
pip3 install --upgrade pip;\
pip install --no-cache-dir -r tests/python/integration/requirements.txt; \
python3 -m pytest tests/python/integration --alluredir=tests/allure_report || ret=$$?; exit $$ret \
)

tests: unit-tests integration-tests

dist-clean:
rm -rf dist
rm -rf dist
6 changes: 5 additions & 1 deletion custom-recipes/jira-services/recipe.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"value": "issue",
"label": "Core: Issue"
},
{
"value": "issue/comments",
"label": "Core: Issue comments"
},
{
"value": "dashboard",
"label": "Core: Dashboard list"
Expand Down Expand Up @@ -207,7 +211,7 @@
"columnRole": "input_datasets_name",
"description": "Name of the column containing the IDs to process",
"mandatory": true,
"visibilityCondition": "['board', 'board/epic', 'board/issue', 'project/versions', 'board/backlog', 'board/sprint', 'board/version', 'project/components'].indexOf(model.endpoint_name) >= 0"
"visibilityCondition": "['issue/comments', 'board', 'board/epic', 'board/issue', 'project/versions', 'board/backlog', 'board/sprint', 'board/version', 'project/components'].indexOf(model.endpoint_name) >= 0"
},
{
"name": "expand",
Expand Down
7 changes: 4 additions & 3 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"id": "jira",
"version": "1.0.0",
"version": "1.0.1",
"meta": {
"label": "Jira",
"description": "Import data from your Jira account",
"author": "Dataiku (Alex Bourret)",
"author": "Dataiku",
"icon": "icon-ticket",
"tags": ["Connector", "CRM"],
"url": "https://www.dataiku.com/product/plugins/jira/",
"licenseInfo": "Apache Software License"
"licenseInfo": "Apache Software License",
"supportLevel": "NOT_SUPPORTED"
}
}
4 changes: 4 additions & 0 deletions python-lib/jira_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
"issue": {
API_QUERY_STRING: {"expand": "{expand}"}
},
"issue/comments": {
API_RESOURCE: "issue/{item_value}",
API_RETURN: {200: "fields.comment.comments"}
},
"issue/createmeta": {
API_RESOURCE: "{endpoint_name}",
API_RETURN: {
Expand Down
3 changes: 2 additions & 1 deletion python-lib/jira_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import jira_api as api
from pagination import Pagination
from utils import extract_data_with_json_path

FILTERING_KEY_WITHOUT_PARAMETER = 0
FILTERING_KEY_WITH_PARAMETER = 1
Expand Down Expand Up @@ -147,7 +148,7 @@ def filter_data(self, data, item_value):
if filtering_key is None:
return arrayed(data)
else:
return arrayed(data[filtering_key])
return arrayed(extract_data_with_json_path(data,filtering_key))

def format_data(self, data):
for key in self.formating:
Expand Down
5 changes: 4 additions & 1 deletion python-lib/pagination.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from utils import extract_data_with_json_path


class Pagination(object):

def __init__(self):
Expand Down Expand Up @@ -47,7 +50,7 @@ def update_next_page(self, data):
else:
counting_key = self.counting_key
if counting_key is not None:
batch_size = len(data.get(counting_key))
batch_size = len(extract_data_with_json_path(data, counting_key))
else:
self.is_last_page = True
batch_size = 1
Expand Down
9 changes: 9 additions & 0 deletions python-lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ def de_float_column(dataframe, column_name):
dataframe[column_name] = dataframe[column_name].astype(int)
dataframe[column_name] = dataframe[column_name].astype(str)
dataframe[column_name] = dataframe[column_name].replace('-1', np.nan)


def extract_data_with_json_path(data, json_path):
if not json_path:
return data
keys = json_path.split(".")
for key in keys:
data = data.get(key, {})
return data

0 comments on commit 397e53c

Please sign in to comment.