-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Jira JQL] Add: support custom JIRA fields and enhance value mapping #1508
[Jira JQL] Add: support custom JIRA fields and enhance value mapping #1508
Conversation
convert list values to concatenated strings support definition of fieldMapping property in query which allows to rename output columns or pick specific members from dict values
…t items are found
i've also provided a PR to update the documentation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this! See my comments. If you have the time, it will be great to add some tests for the parsing logic.
Also, I would like to suggest an alternative syntax for fieldMapping
:
"fieldMapping": {
"customfield_10672": "myCustomField",
"priority.id": "priority",
"fixVersions.name": "myFixVersion"
}
The main change: instead of having an object to describe the mapping we use nested field name (priority.id
) and parse it in the query runner. It makes the parser work a little bit harder, but makes it easier to write queries.
About custom fields - maybe we include only the ones that are in the mapping?
And last thing - 👍 major kudos on including an update to the documentation :-)
@@ -26,15 +26,33 @@ def to_json(self): | |||
return json.dumps({'rows': self.rows, 'columns': self.columns.values()}) | |||
|
|||
|
|||
def parse_issue(issue): | |||
def parse_issue(issue, fieldMapping): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be field_mapping
(we use snake_case
in the Python code).
for listItem in v: | ||
if isinstance(listItem, dict): | ||
if 'member' in mapping: | ||
listValues.append(listItem[mapping['member']]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if mapping['member']
not in listItem
? Better to use listItem.get
or check for this case and raise an explicit error.
Oh, and I would love to understand how you use the JQL integration in Redash. We can do this in private if you prefer (arik at redash.io). |
thanks for the review! please note that this PR are the first lines of python i've ever written, so the code may be not very elegant or not conforming to standards. i've updated the PR:
custom fields are only included when the are part of the "fields" string - or if not "fields" string is given at all. by the new mapping rules which never inject the dicts completely no "rubbish" should be included in the result, so in my opinion it's fine to apply no further filtering to custom fields. they do not harm, but users may get puzzled if they are missing. we use JIRA internally a lot for all sorts of purposes, e.g. organizing projects or purchases. those issue types have custom fields with numbers e.g. costs and we want to use redash to visualize them. |
Thanks! Looking good. Appreciate your cooperation and the tests :) |
Hi guys. There's one issue that I stumbled upon for this particular feature. It doesn't allow me to reference a child element in JSON object if it is deeper within a child element itself. For example this custom field:
There is no way for me to get the element by writing: |
…om-fields [Jira JQL] Add: support custom JIRA fields and enhance value mapping
Enhancements to JQL Query Runner support:
fieldMapping
query property which allows to rename output columns or pick specific members from dict valuesexample JQL:
the three field mappings define: