Skip to content

Commit

Permalink
Added externalJiraLink to model. Done some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
MorkovkAs committed Nov 23, 2022
1 parent 612842c commit 3d47c9a
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 93 deletions.
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Tue Apr 21 18:23:58 MSK 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion report-service-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ group = "com.morkovka.jira-report-tools"
version '0.0.1'

java {
targetCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_11
}

frontend {
Expand Down
4 changes: 2 additions & 2 deletions report-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ dependencies {
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "11"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "11"
}

// clean service and ui files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ data class ReleaseNote(
*/
var taskInKey: String,

/**
* Map to store corresponded Jira keys of issues.
* The key in map is a key from our Jira, the value in map is a key of task in customer's Jira
*/
var jiraKeysMap: MutableMap<String, String>,

/**
* Исходные коды
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ data class Task(
val id: Long,
val key: String,
val link: String,
var externalJiraLink: String,
var summary: String,
var status: String,
var description: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package ru.morkovka.report.entity
data class TaskFeature(
val key: String,
val link: String,
var summary: String
var summary: String,
var externalJiraKey: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ data class FieldsDto(
val status: HashMap<String, Any>?,
val description: String?,
val fixVersions: ArrayList<HashMap<String, String>>?,
val customfield_13700: String?, //our custom field in Jira for external tasks
val comment: CommentsDto?
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TaskMapper {
.map { it["name"] }
.filter(Objects::nonNull)
.collect(Collectors.toList()),
externalJiraLink = taskDto.fields.customfield_13700 ?: "",
comments = (taskDto.fields.comment?.comments ?: arrayListOf<Map<String, Any>>()).stream()
.filter(Objects::nonNull)
.map { it["body"] as String }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import java.util.stream.Collectors

@Service
class ReleaseServiceImpl(
@Value("\${jira.search.default.task.out.paragraph}")
val taskOutParagraph: String,
@Value("\${jira.search.default.task.paragraph}")
val tasksParagraph: String,

@Value("\${jira.search.default.task.in.start}")
val taskInStart: String,
Expand Down Expand Up @@ -95,35 +95,59 @@ class ReleaseServiceImpl(
if (note.taskInKey.isNotEmpty()) {
taskIn = "{Jira:${note.taskInKey}}"
}
val s = "$taskOutParagraph\n" +
"\n\n${taskInParagraph}\n$taskIn" +
"\n\n${commentProperties.sourceCode.paragraph}\n${stringFromMapWithoutTaskKeys(
note.sourceCode, commentProperties.sourceCode.default
)}" +
"\n\n${commentProperties.artifact.paragraph}\n${stringFromMapWithoutTaskKeys(
note.artifact, commentProperties.artifact.default
)}" +
"\n\n${commentProperties.newFeature.paragraph}\n${stringFromFeatures(
note.features, note.jiraKeysMap, commentProperties.newFeature.default
)}" +
"\n\n${commentProperties.databaseChange.paragraph}\n${stringFromMapWithoutTaskKeys(
note.dbChanges, commentProperties.databaseChange.default
)}" +
"\n\n${commentProperties.monitoringChange.paragraph}\n${stringFromMapWithoutTaskKeys(
note.monitoringChanges, commentProperties.monitoringChange.default
)}" +
"\n\n${commentProperties.config.paragraph}\n${stringFromMapWithoutTaskKeys(
note.configs, commentProperties.config.default
)}" +
"\n\n${commentProperties.deployInstruction.paragraph}\n${stringFromMapWithoutTaskKeys(
note.deploy, commentProperties.deployInstruction.default
)}" +
"\n\n${commentProperties.testCase.paragraph}\n${stringFromMapWithTaskKeys(
note.testCase, true, commentProperties.testCase.default
)}" +
"\n\n${commentProperties.rollbackAction.paragraph}\n${stringFromMapWithoutTaskKeys(
note.rollback, commentProperties.rollbackAction.default
)}"
val s = """
{toc:printable=true|maxLevel=7|minLevel=1|type=list|separator=brackets}
$tasksParagraph
$taskInParagraph
* $taskIn
*
${commentProperties.sourceCode.paragraph}
${stringFromMapWithoutTaskKeys(
note.sourceCode, commentProperties.sourceCode.default
)}
${commentProperties.artifact.paragraph}
${stringFromMapWithoutTaskKeys(
note.artifact, commentProperties.artifact.default
)}
${commentProperties.newFeature.paragraph}
${stringFromFeatures(
note.features, commentProperties.newFeature.default
)}
${commentProperties.databaseChange.paragraph}
${stringFromMapWithoutTaskKeys(
note.dbChanges, commentProperties.databaseChange.default
)}
${commentProperties.monitoringChange.paragraph}
${stringFromMapWithoutTaskKeys(
note.monitoringChanges, commentProperties.monitoringChange.default
)}
${commentProperties.config.paragraph}
${stringFromMapWithoutTaskKeys(
note.configs, commentProperties.config.default
)}
${commentProperties.deployInstruction.paragraph}
${stringFromMapWithoutTaskKeys(
note.deploy, commentProperties.deployInstruction.default
)}
${commentProperties.testCase.paragraph}
${stringFromMapWithTaskKeys(
note.testCase, true, commentProperties.testCase.default
)}
${commentProperties.rollbackAction.paragraph}
${stringFromMapWithoutTaskKeys(
note.rollback, commentProperties.rollbackAction.default
)}
"""

logger.info("releaseNoteToString [jiraFixVersion = $jiraFixVersion]: ReleaseNote to String convertation completed")

Expand All @@ -140,30 +164,21 @@ class ReleaseServiceImpl(

private fun getReleaseNoteFromTaskList(taskList: MutableList<Task>): ReleaseNote {
val taskIn = taskList.filter { it.summary.startsWith(taskInStart) }.getOrNull(0)
val jiraKeys: MutableMap<String, String> = mutableMapOf()
val features: MutableMap<String, TaskFeature> = mutableMapOf()
taskList
.filter { !it.summary.startsWith((taskInStart)) }
.forEach {
// Fill collection for mapping jira tasks
val regex = ("(\\[ссылка\\|https*://jcs\\.passport\\.local/(browse|projects/MDM/issues)/MDM-[0-9]+]" +
" на задачу в джире ДИТа)").toRegex(RegexOption.IGNORE_CASE)
val taskOutKey = regex.find(it.description)
if (taskOutKey != null) {
jiraKeys[it.key] = "MDM-[0-9]+".toRegex(RegexOption.IGNORE_CASE).find(taskOutKey.value)?.value ?: ""
}

// Fill release features
features[it.key] = TaskFeature(
key = it.key,
link = it.link,
summary = it.summary
summary = it.summary,
externalJiraKey = "NMDM-[0-9]+".toRegex(RegexOption.IGNORE_CASE).find(it.externalJiraLink)?.value ?: ""
)
}

val note = ReleaseNote(
taskInKey = taskIn?.key ?: "",
jiraKeysMap = jiraKeys,
sourceCode = getCommentsFromTaskListByKeyword(taskList, commentProperties.sourceCode.start),
artifact = getCommentsFromTaskListByKeyword(taskList, commentProperties.artifact.start),
features = features,
Expand Down Expand Up @@ -232,18 +247,20 @@ class ReleaseServiceImpl(
* @return String consisted of features' info.
*/

private fun stringFromFeatures(map: MutableMap<String, TaskFeature>, keyMap: MutableMap<String, String>, defaultValue: String): String {
private fun stringFromFeatures(map: MutableMap<String, TaskFeature>, defaultValue: String): String {
if (map.isEmpty()) {
return defaultValue
}

var s = "||Задача в jira||Задача в jira ТаскДата||Наименование задачи в jira ТаскДата||";
var s = "||Задача ДИТ||Задача ЮД||Наименование||"
map.forEach { (key, task) ->
var taskOutKey = keyMap.getOrDefault(key, " ")
if (taskOutKey != " ") {
taskOutKey = "{Jira:$taskOutKey}"
var externalJiraKey = task.externalJiraKey
if (externalJiraKey.trim().isNotEmpty()) {
externalJiraKey = "{Jira:${externalJiraKey}}"
} else {
externalJiraKey = " "
}
s += "\n|$taskOutKey|{Jira:$key}|${task.summary}|"
s += "\n|$externalJiraKey|{Jira:$key}|${task.summary}|"
}
return s
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,21 @@ class TaskServiceImpl(
return taskList
}

private fun getRequestJsonForJqlQuery(jqlString: String, maxResults: Int) =
"{\n" +
" \"jql\": \"$jqlString ORDER BY key ASC\",\n" +
" \"startAt\": 0,\n" +
" \"maxResults\": $maxResults,\n" +
" \"fields\": [\n" +
" \"summary\",\n" +
" \"status\",\n" +
" \"description\",\n" +
" \"fixVersions\",\n" +
" \"comment\"\n" +
" ]\n" +
"}"
/**
* Generates a JQL search string. customfield_13700 is our custom field for external tasks.
*/
private fun getRequestJsonForJqlQuery(jqlString: String, maxResults: Int) = """{
"jql": "$jqlString ORDER BY key ASC",
"startAt": 0,
"maxResults": $maxResults,
"fields": [
"summary",
"status",
"description",
"fixVersions",
"comment",
"customfield_13700"
]
}"""

}
37 changes: 18 additions & 19 deletions report-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jira:
basic: ${JIRA_AUTH_BASIC:Basic TW9ya292a0E6bXlTdXBlclBhc3M}
paragraph:
font:
size: "h3."
size: "h1."
start:
font:
size: "h2."
Expand All @@ -19,45 +19,44 @@ jira:
project: "DM"
limit: 15
task:
out:
paragraph: "${jira.paragraph.font.size}Задача в Jira заказчика"
paragraph: "${jira.paragraph.font.size}*Ресурсы*"
in:
start: "Релиз КСРД"
paragraph: "${jira.paragraph.font.size}Задача в Jira ТД"
start: "Релиз "
paragraph: "_Задача в Jira:_"
comment:
source-code:
start: "${jira.start.font.size}Исходные коды:"
paragraph: "${jira.paragraph.font.size}Исходные коды"
paragraph: "_Исходные коды:_"
default: ${SOURCE_CODE:*{color:#FF0000}Не заполнено.{color}*}
artifact:
start: "${jira.start.font.size}Артефакты:"
paragraph: "${jira.paragraph.font.size}Артефакты"
paragraph: "${jira.paragraph.font.size}*Артефакты*"
default: ${STORAGE_LINK:*{color:#FF0000}Не заполнено.{color}*}
new-feature:
start: "${jira.start.font.size}Новые функции и исправления:"
paragraph: "${jira.paragraph.font.size}Новые функции и исправления"
paragraph: "${jira.paragraph.font.size}*Новые функции и исправления*"
default: "*{color:#FF0000}Не заполнено.{color}*"
database-change:
start: "${jira.start.font.size}Настройки и изменения в структуре БД, атрибутах, справочниках:"
paragraph: "${jira.paragraph.font.size}Настройки и изменения в структуре БД, атрибутах, справочниках"
default: "Не применимо."
paragraph: "${jira.paragraph.font.size}*Настройки и изменения в структуре БД, атрибутах, справочниках*"
default: "Не требуется."
monitoring-change:
start: "${jira.start.font.size}Информация для подключений и мониторинга:"
paragraph: "${jira.paragraph.font.size}Информация для подключений и мониторинга"
default: "Не применимо."
paragraph: "${jira.paragraph.font.size}*Информация для подключений и мониторинга*"
default: "Не требуется."
config:
start: "${jira.start.font.size}Конфигурация:"
paragraph: "${jira.paragraph.font.size}Конфигурация"
default: "Не применимо."
paragraph: "${jira.paragraph.font.size}*Конфигурация*"
default: "Не требуется."
deploy-instruction:
start: "${jira.start.font.size}Порядок установки и изменения настроек:"
paragraph: "${jira.paragraph.font.size}Порядок установки и изменения настроек"
default: "Не применимо."
paragraph: "${jira.paragraph.font.size}*Порядок установки и изменения настроек*"
default: "Не требуется."
test-case:
start: "${jira.start.font.size}План тестирования у заказчика:"
paragraph: "${jira.paragraph.font.size}План тестирования"
default: "Выполнить соответствующие базовые сценарии для проверки функционала после деплоймента"
paragraph: "${jira.paragraph.font.size}*План тестирования*"
default: "Выполнить соответствующие быстрые тесты для релиза"
rollback-action:
start: "${jira.start.font.size}План отката:"
paragraph: "${jira.paragraph.font.size}План отката"
paragraph: "${jira.paragraph.font.size}*План отката*"
default: "Откатить обновленные артефакты на предыдущие версии."

0 comments on commit 3d47c9a

Please sign in to comment.