Skip to content

Commit 397e53c

Browse files
authored
Merge pull request #2 from dataiku/feature/read-issues-comments
Feature/read issues comments
2 parents 60d9dcb + 7ead09f commit 397e53c

File tree

8 files changed

+63
-21
lines changed

8 files changed

+63
-21
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## [Version 1.0.1](https://github.com/dataiku/dss-plugin-jira/releases/tag/v1.0.1) - Feature release - 2024-08-15
4+
5+
- Add option to retrieve comments on issues

Makefile

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,58 @@ archive_file_name="dss-plugin-${plugin_id}-${plugin_version}.zip"
55
remote_url=`git config --get remote.origin.url`
66
last_commit_id=`git rev-parse HEAD`
77

8+
.DEFAULT_GOAL := plugin
89

9-
plugin:
10+
plugin: dist-clean
1011
@echo "[START] Archiving plugin to dist/ folder..."
1112
@cat plugin.json | json_pp > /dev/null
12-
@rm -rf dist
1313
@mkdir dist
1414
@echo "{\"remote_url\":\"${remote_url}\",\"last_commit_id\":\"${last_commit_id}\"}" > release_info.json
1515
@git archive -v -9 --format zip -o dist/${archive_file_name} HEAD
16+
@if [[ -d tests ]]; then \
17+
zip --delete dist/${archive_file_name} "tests/*"; \
18+
fi
1619
@zip -u dist/${archive_file_name} release_info.json
1720
@rm release_info.json
1821
@echo "[SUCCESS] Archiving plugin to dist/ folder: Done!"
1922

23+
dev: dist-clean
24+
@echo "[START] Archiving plugin to dist/ folder... (dev mode)"
25+
@cat plugin.json | json_pp > /dev/null
26+
@mkdir dist
27+
@zip -v -9 dist/${archive_file_name} -r . --exclude "tests/*" "env/*" ".git/*" ".pytest_cache/*" ".idea/*" "dist/*"
28+
@echo "[SUCCESS] Archiving plugin to dist/ folder: Done!"
29+
2030
unit-tests:
21-
@echo "[START] Running unit tests..."
31+
@echo "Running unit tests..."
2232
@( \
23-
PYTHON_VERSION=`python3 -V 2>&1 | sed 's/[^0-9]*//g' | cut -c 1,2`; \
24-
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']]);"`; \
25-
if [ ! $$PYTHON_VERSION_IS_CORRECT ]; then echo "Python version $$PYTHON_VERSION is not in acceptedPythonInterpreters"; exit 1; fi; \
33+
PYTHON_VERSION=`python3 -c "import sys; print('PYTHON{}{}'.format(sys.version_info.major, sys.version_info.minor))"`; \
34+
PYTHON_VERSION_IS_CORRECT=`cat code-env/python/desc.json | python3 -c "import sys, json; print('$$PYTHON_VERSION' in json.load(sys.stdin)['acceptedPythonInterpreters']);"`; \
35+
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; \
2636
)
2737
@( \
38+
rm -rf ./env/; \
2839
python3 -m venv env/; \
2940
source env/bin/activate; \
30-
pip3 install --upgrade pip; \
31-
pip install --no-cache-dir -r tests/python/requirements.txt; \
41+
pip install --upgrade pip;\
42+
pip install --no-cache-dir -r tests/python/unit/requirements.txt; \
3243
pip install --no-cache-dir -r code-env/python/spec/requirements.txt; \
3344
export PYTHONPATH="$(PYTHONPATH):$(PWD)/python-lib"; \
34-
pytest -o junit_family=xunit2 --junitxml=unit.xml tests/python/unit || true; \
35-
deactivate; \
45+
python3 -m pytest tests/python/unit --alluredir=tests/allure_report || ret=$$?; exit $$ret \
3646
)
37-
@echo "[SUCCESS] Running unit tests: Done!"
3847

3948
integration-tests:
40-
@echo "[START] Running integration tests..."
41-
# TODO add integration tests
42-
@echo "[SUCCESS] Running integration tests: Done!"
49+
@echo "Running integration tests..."
50+
@( \
51+
rm -rf ./env/; \
52+
python3 -m venv env/; \
53+
source env/bin/activate; \
54+
pip3 install --upgrade pip;\
55+
pip install --no-cache-dir -r tests/python/integration/requirements.txt; \
56+
python3 -m pytest tests/python/integration --alluredir=tests/allure_report || ret=$$?; exit $$ret \
57+
)
4358

4459
tests: unit-tests integration-tests
4560

4661
dist-clean:
47-
rm -rf dist
62+
rm -rf dist

custom-recipes/jira-services/recipe.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
"value": "issue",
5959
"label": "Core: Issue"
6060
},
61+
{
62+
"value": "issue/comments",
63+
"label": "Core: Issue comments"
64+
},
6165
{
6266
"value": "dashboard",
6367
"label": "Core: Dashboard list"
@@ -207,7 +211,7 @@
207211
"columnRole": "input_datasets_name",
208212
"description": "Name of the column containing the IDs to process",
209213
"mandatory": true,
210-
"visibilityCondition": "['board', 'board/epic', 'board/issue', 'project/versions', 'board/backlog', 'board/sprint', 'board/version', 'project/components'].indexOf(model.endpoint_name) >= 0"
214+
"visibilityCondition": "['issue/comments', 'board', 'board/epic', 'board/issue', 'project/versions', 'board/backlog', 'board/sprint', 'board/version', 'project/components'].indexOf(model.endpoint_name) >= 0"
211215
},
212216
{
213217
"name": "expand",

plugin.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"id": "jira",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"meta": {
55
"label": "Jira",
66
"description": "Import data from your Jira account",
7-
"author": "Dataiku (Alex Bourret)",
7+
"author": "Dataiku",
88
"icon": "icon-ticket",
99
"tags": ["Connector", "CRM"],
1010
"url": "https://www.dataiku.com/product/plugins/jira/",
11-
"licenseInfo": "Apache Software License"
11+
"licenseInfo": "Apache Software License",
12+
"supportLevel": "NOT_SUPPORTED"
1213
}
1314
}

python-lib/jira_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
"issue": {
6161
API_QUERY_STRING: {"expand": "{expand}"}
6262
},
63+
"issue/comments": {
64+
API_RESOURCE: "issue/{item_value}",
65+
API_RETURN: {200: "fields.comment.comments"}
66+
},
6367
"issue/createmeta": {
6468
API_RESOURCE: "{endpoint_name}",
6569
API_RETURN: {

python-lib/jira_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import jira_api as api
77
from pagination import Pagination
8+
from utils import extract_data_with_json_path
89

910
FILTERING_KEY_WITHOUT_PARAMETER = 0
1011
FILTERING_KEY_WITH_PARAMETER = 1
@@ -147,7 +148,7 @@ def filter_data(self, data, item_value):
147148
if filtering_key is None:
148149
return arrayed(data)
149150
else:
150-
return arrayed(data[filtering_key])
151+
return arrayed(extract_data_with_json_path(data,filtering_key))
151152

152153
def format_data(self, data):
153154
for key in self.formating:

python-lib/pagination.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from utils import extract_data_with_json_path
2+
3+
14
class Pagination(object):
25

36
def __init__(self):
@@ -47,7 +50,7 @@ def update_next_page(self, data):
4750
else:
4851
counting_key = self.counting_key
4952
if counting_key is not None:
50-
batch_size = len(data.get(counting_key))
53+
batch_size = len(extract_data_with_json_path(data, counting_key))
5154
else:
5255
self.is_last_page = True
5356
batch_size = 1

python-lib/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,12 @@ def de_float_column(dataframe, column_name):
99
dataframe[column_name] = dataframe[column_name].astype(int)
1010
dataframe[column_name] = dataframe[column_name].astype(str)
1111
dataframe[column_name] = dataframe[column_name].replace('-1', np.nan)
12+
13+
14+
def extract_data_with_json_path(data, json_path):
15+
if not json_path:
16+
return data
17+
keys = json_path.split(".")
18+
for key in keys:
19+
data = data.get(key, {})
20+
return data

0 commit comments

Comments
 (0)