From 13d2472fb5eed4c6d5bf62e9fcefe85b25210ef2 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Mon, 26 Aug 2024 16:44:06 +0200 Subject: [PATCH 01/12] sync only changed parts in jira sync --- .../gropius/sync/jira/JiraDataService.kt | 31 ++++++----- .../main/kotlin/gropius/sync/jira/JiraSync.kt | 51 ++++++++++++++----- .../gropius/sync/jira/model/ProjectQuery.kt | 11 +++- 3 files changed, 68 insertions(+), 25 deletions(-) diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt index 3fd233fa..7ed9dfad 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt @@ -256,6 +256,24 @@ class JiraDataService( } } + suspend fun collectRequestUsers( + imsProject: IMSProject, users: List + ): List { + val imsConfig = IMSConfig(helper, imsProject.ims().value, imsProject.ims().value.template().value) + val rawUserList = users.toMutableList() + if (imsConfig.readUser != null) { + val imsUser = neoOperations.findById(imsConfig.readUser, IMSUser::class.java).awaitSingleOrNull() + ?: throw IllegalArgumentException("Read user not found") + if (imsUser.ims().value != imsProject.ims().value) { + TODO("Error handling") + } + rawUserList.add(imsUser) + } + val userList = rawUserList.distinct() + logger.info("Requesting with users: $userList") + return userList + } + /** * Process a request for a given set of users * @@ -274,18 +292,7 @@ class JiraDataService( body: T? = null, crossinline urlBuilder: URLBuilder .(URLBuilder) -> Unit ): Pair { - val imsConfig = IMSConfig(helper, imsProject.ims().value, imsProject.ims().value.template().value) - val rawUserList = users.toMutableList() - if (imsConfig.readUser != null) { - val imsUser = neoOperations.findById(imsConfig.readUser, IMSUser::class.java).awaitSingleOrNull() - ?: throw IllegalArgumentException("Read user not found") - if (imsUser.ims().value != imsProject.ims().value) { - TODO("Error handling") - } - rawUserList.add(imsUser) - } - val userList = rawUserList.distinct() - logger.info("Requesting with users: $userList") + val userList = collectRequestUsers(imsProject, users) return tokenManager.executeUntilWorking(imsProject.ims().value, userList) { sendRequest( imsProject, requestMethod, body, urlBuilder, it diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt index 1c2804f5..bedc3efa 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt @@ -17,6 +17,9 @@ import io.ktor.http.* import kotlinx.serialization.json.* import org.slf4j.LoggerFactory import org.springframework.stereotype.Component +import java.time.OffsetDateTime +import java.time.ZoneId +import java.time.format.DateTimeFormatter import kotlin.io.encoding.ExperimentalEncodingApi /** @@ -40,6 +43,10 @@ final class JiraSync( val issueDataService: IssueDataService ) : AbstractSync(collectedSyncInfo) { + companion object { + val jqlFormatter = DateTimeFormatter.ofPattern("\"yyyy-MM-dd HH:mm\"") + } + /** * Logger used to print notifications */ @@ -92,15 +99,14 @@ final class JiraSync( } for (imsProject in imsProjects) { - val issueList = mutableListOf() - fetchIssueList(imsProject, issueList) + val issueList = fetchIssueList(imsProject) fetchIssueContent(issueList, imsProject) } } @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueContentChangelog( - issueList: MutableList, imsProject: IMSProject + issueList: List, imsProject: IMSProject ) { for (issueId in issueList) { var startAt = 0 @@ -124,7 +130,7 @@ final class JiraSync( @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueContentComments( - issueList: MutableList, imsProject: IMSProject + issueList: List, imsProject: IMSProject ) { for (issueId in issueList) { var startAt = 0 @@ -149,7 +155,7 @@ final class JiraSync( @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueContent( - issueList: MutableList, imsProject: IMSProject + issueList: List, imsProject: IMSProject ) { logger.info("ISSUE LIST $issueList") fetchIssueContentChangelog(issueList, imsProject) @@ -158,16 +164,36 @@ final class JiraSync( @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueList( - imsProject: IMSProject, issueList: MutableList - ) { + imsProject: IMSProject + ): List { + val issueList = mutableListOf() var startAt = 0 + val lastSuccessfulSync: OffsetDateTime? = null while (true) { val imsProjectConfig = IMSProjectConfig(helper, imsProject) - val issueResponse = jiraDataService.request(imsProject, listOf(), HttpMethod.Get) { - appendPathSegments("search") - parameters.append("jql", "project=${imsProjectConfig.repo}") - parameters.append("expand", "names,schema,editmeta,changelog") - parameters.append("startAt", "$startAt") + val userList = jiraDataService.collectRequestUsers(imsProject, listOf()) + val issueResponse = jiraDataService.tokenManager.executeUntilWorking(imsProject.ims().value, userList) { + val userTimeZone = ZoneId.of( + jiraDataService.sendRequest( + imsProject, HttpMethod.Get, null, { + appendPathSegments("user") + }, it + ).get().body().timeZone + ) + var query = "project=${imsProjectConfig.repo}" + if (lastSuccessfulSync != null) { + query = "project=${imsProjectConfig.repo} AND updated > ${ + lastSuccessfulSync.atZoneSameInstant(userTimeZone).format(jqlFormatter) + }" + } + jiraDataService.sendRequest( + imsProject, HttpMethod.Get, null, { + appendPathSegments("search") + parameters.append("jql", query) + parameters.append("expand", "names,schema,editmeta,changelog") + parameters.append("startAt", "$startAt") + }, it + ) }.second.body() issueResponse.issues(imsProject).forEach { issueList.add(it.jiraId) @@ -176,6 +202,7 @@ final class JiraSync( startAt = issueResponse.startAt + issueResponse.issues.size if (startAt >= issueResponse.total) break } + return issueList } override suspend fun findUnsyncedIssues(imsProject: IMSProject): List { diff --git a/jira/src/main/kotlin/gropius/sync/jira/model/ProjectQuery.kt b/jira/src/main/kotlin/gropius/sync/jira/model/ProjectQuery.kt index 5154df7f..8a0f82de 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/model/ProjectQuery.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/model/ProjectQuery.kt @@ -165,4 +165,13 @@ data class ProjectQuery( ) { fun issues(imsProject: IMSProject): List = issues.map { it.data(imsProject, names ?: JsonObject(mapOf()), schema ?: JsonObject(mapOf())) } -} \ No newline at end of file +} + +/** + * Kotlin representation of the UserQuery JSON + * @param timeZone The timeZone of the user + */ +@Serializable +data class UserQuery( + val timeZone: String +) {} \ No newline at end of file From 08c17a04492937a5684dd55f78f297b0d8fcb777 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 11:03:22 +0200 Subject: [PATCH 02/12] fetch only changed stuff --- .../main/kotlin/gropius/sync/jira/JiraSync.kt | 36 ++++++++++-- .../kotlin/gropius/sync/jira/SyncStatus.kt | 58 +++++++++++++++++++ 2 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt index bedc3efa..74cda8da 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt @@ -31,6 +31,7 @@ import kotlin.io.encoding.ExperimentalEncodingApi * @param collectedSyncInfo the collected sync info * @param loadBalancedDataFetcher the load balanced data fetcher * @param issueDataService the data service for issues + * @param syncStatusService the sync status service */ @Component final class JiraSync( @@ -40,7 +41,8 @@ final class JiraSync( val imsConfigManager: IMSConfigManager, collectedSyncInfo: CollectedSyncInfo, val loadBalancedDataFetcher: LoadBalancedDataFetcher = LoadBalancedDataFetcher(), - val issueDataService: IssueDataService + val issueDataService: IssueDataService, + val syncStatusService: SyncStatusService ) : AbstractSync(collectedSyncInfo) { companion object { @@ -99,8 +101,11 @@ final class JiraSync( } for (imsProject in imsProjects) { - val issueList = fetchIssueList(imsProject) + val (issueList, lastSeenTime) = fetchIssueList(imsProject) fetchIssueContent(issueList, imsProject) + if (lastSeenTime != null) { + syncStatusService.updateTime(imsProject.rawId!!, lastSeenTime) + } } } @@ -165,10 +170,12 @@ final class JiraSync( @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueList( imsProject: IMSProject - ): List { + ): Pair, OffsetDateTime?> { val issueList = mutableListOf() var startAt = 0 - val lastSuccessfulSync: OffsetDateTime? = null + val lastSuccessfulSync: OffsetDateTime? = + syncStatusService.findByImsProject(imsProject.rawId!!)?.lastSuccessfulSync + val times = mutableListOf() while (true) { val imsProjectConfig = IMSProjectConfig(helper, imsProject) val userList = jiraDataService.collectRequestUsers(imsProject, listOf()) @@ -198,11 +205,30 @@ final class JiraSync( issueResponse.issues(imsProject).forEach { issueList.add(it.jiraId) issueDataService.insertIssue(imsProject, it) + for (comment in it.comments.values) { + times.add( + OffsetDateTime.parse( + comment.created, IssueData.formatter + ) + ) + times.add( + OffsetDateTime.parse( + comment.updated, IssueData.formatter + ) + ) + } + for (history in it.changelog.histories) { + times.add( + OffsetDateTime.parse( + history.created, IssueData.formatter + ) + ) + } } startAt = issueResponse.startAt + issueResponse.issues.size if (startAt >= issueResponse.total) break } - return issueList + return issueList to times.maxOrNull() } override suspend fun findUnsyncedIssues(imsProject: IMSProject): List { diff --git a/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt b/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt new file mode 100644 index 00000000..34931d84 --- /dev/null +++ b/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt @@ -0,0 +1,58 @@ +package gropius.sync.jira + +import kotlinx.coroutines.reactor.awaitSingle +import org.bson.types.ObjectId +import org.springframework.data.annotation.Id +import org.springframework.data.mongodb.core.index.Indexed +import org.springframework.data.mongodb.core.mapping.Document +import org.springframework.data.mongodb.repository.ReactiveMongoRepository +import org.springframework.stereotype.Repository +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import java.time.OffsetDateTime + +/** + * Base class for storing information about general sync status + * @param imsProject IMS project ID + * @param lastSuccessfulSync Timestamp of the last successful sync. nullable for future use + */ +@Document +data class SyncStatus( + @Indexed + val imsProject: String, + @Indexed + var lastSuccessfulSync: OffsetDateTime?, +) { + /** + * MongoDB ID + */ + @Id + var id: ObjectId? = null +} + +/** + * Repository for accessing the sync status + */ +@Repository +interface SyncStatusRepository : ReactiveMongoRepository { + /** + * Find using the IMSProject ID + */ + suspend fun findByImsProject( + imsProject: String + ): SyncStatus? +} + +/** + * Service for modifying the sync status + */ +@Service +class SyncStatusService(val syncStatusRepository: SyncStatusRepository) : SyncStatusRepository by syncStatusRepository { + + @Transactional + suspend fun updateTime(imsProject: String, lastSuccessfulSync: OffsetDateTime) { + val status = syncStatusRepository.findByImsProject(imsProject) ?: SyncStatus(imsProject, null) + status.lastSuccessfulSync = lastSuccessfulSync + syncStatusRepository.save(status).awaitSingle() + } +} From 941bc658480f78008f2434953a212ef4a9c206bd Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:15:51 +0200 Subject: [PATCH 03/12] do not send /changelog with jira and get it working --- .../main/kotlin/gropius/sync/jira/JiraSync.kt | 17 +++++++++++++++-- .../gropius/sync/jira/config/IMSConfig.kt | 6 ++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt index 74cda8da..94d3ae62 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt @@ -8,6 +8,7 @@ import gropius.model.template.IMSTemplate import gropius.model.template.IssueState import gropius.model.user.User import gropius.sync.* +import gropius.sync.jira.config.IMSConfig import gropius.sync.jira.config.IMSConfigManager import gropius.sync.jira.config.IMSProjectConfig import gropius.sync.jira.model.* @@ -163,8 +164,11 @@ final class JiraSync( issueList: List, imsProject: IMSProject ) { logger.info("ISSUE LIST $issueList") - fetchIssueContentChangelog(issueList, imsProject) + val imsConfig = IMSConfig(helper, imsProject.ims().value, imsProject.ims().value.template().value) fetchIssueContentComments(issueList, imsProject) + if (imsConfig.isCloud != false) { + fetchIssueContentChangelog(issueList, imsProject) + } } @OptIn(ExperimentalEncodingApi::class) @@ -183,7 +187,7 @@ final class JiraSync( val userTimeZone = ZoneId.of( jiraDataService.sendRequest( imsProject, HttpMethod.Get, null, { - appendPathSegments("user") + appendPathSegments("myself") }, it ).get().body().timeZone ) @@ -193,6 +197,7 @@ final class JiraSync( lastSuccessfulSync.atZoneSameInstant(userTimeZone).format(jqlFormatter) }" } + logger.info("With $lastSuccessfulSync, ${imsProjectConfig.repo} and $userTimeZone, the query is '$query'") jiraDataService.sendRequest( imsProject, HttpMethod.Get, null, { appendPathSegments("search") @@ -224,6 +229,14 @@ final class JiraSync( ) ) } + val updated = it.fields["updated"] + if (updated != null) { + times.add( + OffsetDateTime.parse( + updated.jsonPrimitive.content, IssueData.formatter + ) + ) + } } startAt = issueResponse.startAt + issueResponse.issues.size if (startAt >= issueResponse.total) break diff --git a/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt b/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt index 5c4595ef..9da295eb 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt @@ -22,7 +22,8 @@ data class IMSConfig( val rootUrl: URI, val imsTemplate: IMSTemplate, val defaultType: String?, - val defaultTemplate: String? + val defaultTemplate: String?, + val isCloud: Boolean? ) { /** * @param ims the Gropius ims to use as input @@ -37,7 +38,8 @@ data class IMSConfig( rootUrl = URI(helper.parseString(ims.templatedFields["root-url"])!!), imsTemplate = imsTemplate, defaultType = helper.parseString(ims.templatedFields["default-type"]), - defaultTemplate = helper.parseString(ims.templatedFields["default-template"]) + defaultTemplate = helper.parseString(ims.templatedFields["default-template"]), + isCloud = helper.parseString(ims.templatedFields["jira-edition"])?.let { it == "CLOUD" }, ) companion object { From 94fee21820b93b6ea405c27adf6bc62a21f74493 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:31:45 +0200 Subject: [PATCH 04/12] dokka collectRequestUsers --- jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt index 7ed9dfad..4618b906 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraDataService.kt @@ -256,6 +256,13 @@ class JiraDataService( } } + /** + * Collect list of users to request with using + * + * @param imsProject the project to work on + * @param users the list of users specific to this TimelineItem + * @return all users sorted by most fitting first + */ suspend fun collectRequestUsers( imsProject: IMSProject, users: List ): List { From b3a590a6bd189c0d1c4051356d2c1370ced90a57 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:35:20 +0200 Subject: [PATCH 05/12] dokka --- .../main/kotlin/gropius/sync/jira/JiraSync.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt index 94d3ae62..caeb17d8 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt @@ -47,6 +47,9 @@ final class JiraSync( ) : AbstractSync(collectedSyncInfo) { companion object { + /** + * Formatter for JQL dates + */ val jqlFormatter = DateTimeFormatter.ofPattern("\"yyyy-MM-dd HH:mm\"") } @@ -110,6 +113,11 @@ final class JiraSync( } } + /** + * Fetch the changelog of the issues + * @param issueList the list of issues + * @param imsProject the IMS project + */ @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueContentChangelog( issueList: List, imsProject: IMSProject @@ -134,6 +142,11 @@ final class JiraSync( } } + /** + * Fetch the comments of the issues + * @param issueList the list of issues + * @param imsProject the IMS project + */ @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueContentComments( issueList: List, imsProject: IMSProject @@ -159,6 +172,11 @@ final class JiraSync( } } + /** + * Fetch the content of the issues + * @param issueList the list of issues + * @param imsProject the IMS project + */ @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueContent( issueList: List, imsProject: IMSProject @@ -171,6 +189,11 @@ final class JiraSync( } } + /** + * Fetch the list of changed issues + * @param imsProject the IMS project + * @return issueList the list of issues + */ @OptIn(ExperimentalEncodingApi::class) private suspend fun fetchIssueList( imsProject: IMSProject From 96d1eca495e9897076c9c1100a16ea5af5cffaf4 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:36:03 +0200 Subject: [PATCH 06/12] dokka --- jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt b/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt index 9da295eb..d69de16b 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt @@ -15,6 +15,7 @@ import java.net.URI * @param imsTemplate the template of the current IMS * @param defaultType the type of newly created issues * @param defaultTemplate the template of newly created issues + * @param isCloud true if cloud, false if data center, null if not specified */ data class IMSConfig( val botUser: String, From aa17290ba460cdd247243a1003be89b6b403b445 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:40:04 +0200 Subject: [PATCH 07/12] always default to cloud --- jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt | 2 +- jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt index caeb17d8..fce4dbcc 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt @@ -184,7 +184,7 @@ final class JiraSync( logger.info("ISSUE LIST $issueList") val imsConfig = IMSConfig(helper, imsProject.ims().value, imsProject.ims().value.template().value) fetchIssueContentComments(issueList, imsProject) - if (imsConfig.isCloud != false) { + if (imsConfig.isCloud) { fetchIssueContentChangelog(issueList, imsProject) } } diff --git a/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt b/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt index d69de16b..58523200 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt @@ -24,7 +24,7 @@ data class IMSConfig( val imsTemplate: IMSTemplate, val defaultType: String?, val defaultTemplate: String?, - val isCloud: Boolean? + val isCloud: Boolean ) { /** * @param ims the Gropius ims to use as input @@ -40,7 +40,7 @@ data class IMSConfig( imsTemplate = imsTemplate, defaultType = helper.parseString(ims.templatedFields["default-type"]), defaultTemplate = helper.parseString(ims.templatedFields["default-template"]), - isCloud = helper.parseString(ims.templatedFields["jira-edition"])?.let { it == "CLOUD" }, + isCloud = helper.parseString(ims.templatedFields["jira-edition"])?.let { it == "CLOUD" } ?: true, ) companion object { From 014804ab47e9922f3548a546f8755d100aa86d72 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:40:42 +0200 Subject: [PATCH 08/12] dokka for isCloud --- jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt b/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt index 58523200..d3904183 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/config/IMSConfig.kt @@ -15,7 +15,7 @@ import java.net.URI * @param imsTemplate the template of the current IMS * @param defaultType the type of newly created issues * @param defaultTemplate the template of newly created issues - * @param isCloud true if cloud, false if data center, null if not specified + * @param isCloud true if cloud, false if data center */ data class IMSConfig( val botUser: String, From 0dbbdd678679be61814dfd3312ca0478659cd1d3 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:41:43 +0200 Subject: [PATCH 09/12] useless dokka --- jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt b/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt index 34931d84..c4412ae8 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt @@ -49,6 +49,11 @@ interface SyncStatusRepository : ReactiveMongoRepository { @Service class SyncStatusService(val syncStatusRepository: SyncStatusRepository) : SyncStatusRepository by syncStatusRepository { + /** + * Update the Time saved in the SyncStatusService + * @param imsProject IMS project ID of the SyncStatusService + * @param lastSuccessfulSync New Timestamp of the last successful sync + */ @Transactional suspend fun updateTime(imsProject: String, lastSuccessfulSync: OffsetDateTime) { val status = syncStatusRepository.findByImsProject(imsProject) ?: SyncStatus(imsProject, null) From 2adc7f03c2a13e2368756f1bbab80527b129f499 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:42:16 +0200 Subject: [PATCH 10/12] even more useless dokka --- jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt b/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt index c4412ae8..67fafc25 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/SyncStatus.kt @@ -37,6 +37,7 @@ data class SyncStatus( interface SyncStatusRepository : ReactiveMongoRepository { /** * Find using the IMSProject ID + * @param imsProject IMS project ID */ suspend fun findByImsProject( imsProject: String From 47ba7f7f47a12acc43335584ae5751562e890fd2 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:42:51 +0200 Subject: [PATCH 11/12] brackets around a single break, waah, waah, waah --- jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt index fce4dbcc..e50e1efb 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt @@ -262,7 +262,9 @@ final class JiraSync( } } startAt = issueResponse.startAt + issueResponse.issues.size - if (startAt >= issueResponse.total) break + if (startAt >= issueResponse.total) { + break + } } return issueList to times.maxOrNull() } From 8cf3ebd07ce301810b0dc5edad61e48820d05d96 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Tue, 27 Aug 2024 12:43:44 +0200 Subject: [PATCH 12/12] disgustify variable name --- jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt index e50e1efb..3150f9a0 100644 --- a/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt +++ b/jira/src/main/kotlin/gropius/sync/jira/JiraSync.kt @@ -50,7 +50,7 @@ final class JiraSync( /** * Formatter for JQL dates */ - val jqlFormatter = DateTimeFormatter.ofPattern("\"yyyy-MM-dd HH:mm\"") + val JQL_FORMATTER = DateTimeFormatter.ofPattern("\"yyyy-MM-dd HH:mm\"") } /** @@ -217,7 +217,7 @@ final class JiraSync( var query = "project=${imsProjectConfig.repo}" if (lastSuccessfulSync != null) { query = "project=${imsProjectConfig.repo} AND updated > ${ - lastSuccessfulSync.atZoneSameInstant(userTimeZone).format(jqlFormatter) + lastSuccessfulSync.atZoneSameInstant(userTimeZone).format(JQL_FORMATTER) }" } logger.info("With $lastSuccessfulSync, ${imsProjectConfig.repo} and $userTimeZone, the query is '$query'")