Skip to content

Commit

Permalink
RD-15160: Add e-mail addresses (creator and assignee) to the issues t…
Browse files Browse the repository at this point in the history
…able (#11)

Also:
* Added quotes to filter values to protect from spaces, '@',
* Fixed a bit the phrasing in the field descriptions.
  • Loading branch information
bgaidioz authored Nov 25, 2024
1 parent 37c3587 commit 39a60ba
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ protected void processFields(
assignee.map(a -> a.get("accountId")).orElse(null),
columns);

addToRow(
"assignee_email_address",
rowBuilder,
assignee.map(a -> a.get("emailAddress")).orElse(null),
columns);

addToRow(
"assignee_display_name",
rowBuilder,
Expand All @@ -61,6 +67,12 @@ protected void processFields(
creator.map(c -> c.get("accountId")).orElse(null),
columns);

addToRow(
"creator_email_address",
rowBuilder,
creator.map(c -> c.get("emailAddress")).orElse(null),
columns);

addToRow(
"creator_display_name",
rowBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ static String mapOperator(Operator operator) {
}

static String mapValue(Value value) {
return switch (value) {
String s = switch (value) {
case Value v when v.hasString() -> v.getString().getV();
case Value v when v.hasTime() -> {
OffsetTime time = (OffsetTime) extractValueFactory.extractValue(value);
yield "\"" + time.format(formatter) + "\"";
yield time.format(formatter);
}
case Value v when (v.hasTimestamp() || v.hasDate()) -> {
OffsetDateTime time = (OffsetDateTime) extractValueFactory.extractValue(value);
yield "\"" + time.format(formatter) + "\"";
yield time.format(formatter);
}
default -> throw new IllegalArgumentException("Unexpected value: " + value);
};
return "\"" + s + "\"";
}

private static String getIssueJqlKey(String columnName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ protected LinkedHashMap<String, ColumnDefinition> buildColumnDefinitions() {
"assignee_account_id",
"Account Id the user/application that the issue is assigned to work.",
createStringType()));
columnDefinitions.put(
"assignee_email_address",
createColumn(
"assignee_email_address",
"The e-mail address of the user or application to whom the issue is assigned",
createStringType()));
columnDefinitions.put(
"assignee_display_name",
createColumn(
Expand All @@ -199,6 +205,12 @@ protected LinkedHashMap<String, ColumnDefinition> buildColumnDefinitions() {
"creator_account_id",
"Account Id of the user/application that created the issue.",
createStringType()));
columnDefinitions.put(
"creator_email_address",
createColumn(
"creator_email_address",
"The e-mail address of the user/application that created the issue",
createStringType()));
columnDefinitions.put(
"creator_display_name",
createColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ public Row next() {
@Override
public DASJiraPage<IssueBean> fetchPage(long offset) {
try {
String jql = DASJiraJqlQueryBuilder.buildJqlQuery(quals);
var result =
issueSearchApi.searchForIssuesUsingJql(
DASJiraJqlQueryBuilder.buildJqlQuery(quals),
jql,
Math.toIntExact(offset),
withMaxResultOrLimit(limit),
null,
Expand Down Expand Up @@ -214,25 +215,37 @@ protected LinkedHashMap<String, ColumnDefinition> buildColumnDefinitions() {
"assignee_account_id",
createColumn(
"assignee_account_id",
"Account Id the user/application that the issue is assigned to work",
"The account ID of the user or application to whom the issue is assigned",
createStringType()));
columns.put(
"assignee_email_address",
createColumn(
"assignee_email_address",
"The e-mail address of the user or application to whom the issue is assigned",
createStringType()));
columns.put(
"assignee_display_name",
createColumn(
"assignee_display_name",
"Display name the user/application that the issue is assigned to work",
"The display name of the user or application to whom the issue is assigned",
createStringType()));
columns.put(
"creator_account_id",
createColumn(
"creator_account_id",
"Account Id of the user/application that created the issue",
"The account ID of the user/application that created the issue",
createStringType()));
columns.put(
"creator_email_address",
createColumn(
"creator_email_address",
"The e-mail address of the user/application that created the issue",
createStringType()));
columns.put(
"creator_display_name",
createColumn(
"creator_display_name",
"Display name of the user/application that created the issue",
"The display name of the user/application that created the issue",
createStringType()));
columns.put(
"created",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void shouldMapValues() {
valueFactory.createValue(
new ValueTypeTuple("2021-01-01T00:00:00Z", createTimestampType())));

assertEquals("DAS", string);
assertEquals("\"DAS\"", string);
assertEquals("\"2021-01-01 00:00\"", timestamp);
assertThrows(
IllegalArgumentException.class,
Expand Down Expand Up @@ -80,6 +80,6 @@ public void shouldGenerateJqlQuery() {
"due_date")));

assertEquals(
"summary = DAS AND created >= \"2021-01-01 00:00\" AND due <= \"2021-01-01 00:00\"", result);
"summary = \"DAS\" AND created >= \"2021-01-01 00:00\" AND due <= \"2021-01-01 00:00\"", result);
}
}

0 comments on commit 39a60ba

Please sign in to comment.