From c54269a543024a32eef9a9f344d3d00ccf9cf4b1 Mon Sep 17 00:00:00 2001 From: Shoma Nishitateno Date: Wed, 23 May 2018 10:44:50 +0900 Subject: [PATCH 1/3] Update: version to 0.1.0b3 --- build.sbt | 2 +- src/main/resources/application.conf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 374eb99..5688f26 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ name := "backlog-migration-cybozulive" lazy val commonSettings = Seq( - version := "0.1.0b2", + version := "0.1.0b3-SNAPSHOT", scalaVersion := "2.12.6", libraryDependencies ++= Seq( "org.fusesource.jansi" % "jansi" % "1.17", diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 7a2f63d..2d625ba 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -1,14 +1,14 @@ app { name = "Backlog Migration for CybozuLive" - version = "0.1.0b2" + version = "0.1.0b3-SNAPSHOT" title = ${app.name} ${app.version} (c) nulab.inc fileName = backlog-migration-cybozulive-${app.version}.jar language = default dataDirectory = "./backlog-migration" mixpanel { - token = "5be8b628b7103858164142d02cb38347" - backlogtoolToken = "0512c52e553b9283143bed99e61c27e4" + token = "6aad3862b3514d664ebb4501f86f42c8" + backlogtoolToken = "6aad3862b3514d664ebb4501f86f42c8" product = "cybozulive" } } From 95dca8e558ec3d04e67cf5bbdce59b0b14342be9 Mon Sep 17 00:00:00 2001 From: Shoma Nishitateno Date: Thu, 24 May 2018 14:43:39 +0900 Subject: [PATCH 2/3] Fix: duplicate id. BLGMIGRATION-695 --- .../backlog/c2b/services/BacklogExport.scala | 68 +++++++++++-------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/src/main/scala/com/nulabinc/backlog/c2b/services/BacklogExport.scala b/src/main/scala/com/nulabinc/backlog/c2b/services/BacklogExport.scala index ce4b3e2..7ada1c0 100644 --- a/src/main/scala/com/nulabinc/backlog/c2b/services/BacklogExport.scala +++ b/src/main/scala/com/nulabinc/backlog/c2b/services/BacklogExport.scala @@ -41,9 +41,9 @@ object BacklogExport extends Logger { _ <- versions(config) _ <- exportIssueTypes(config, issueTypes) _ <- customFields(config) - _ <- todos(config, issueTypes(IssueType.ToDo), openStatusName) - _ <- events(config, issueTypes(IssueType.Event)) - _ <- forums(config, issueTypes(IssueType.Forum)) + todoCount <- todos(config, issueTypes(IssueType.ToDo), openStatusName, 0) + eventCount <- events(config, issueTypes(IssueType.Event), todoCount) + _ <- forums(config, issueTypes(IssueType.Forum), eventCount) _ <- finish } yield () @@ -125,7 +125,8 @@ object BacklogExport extends Logger { def todos(config: Config, issueType: CybozuIssueType, - openStatusName: String)(implicit mappingContext: MappingContext): AppProgram[Unit] = { + openStatusName: String, + startIndex: Int)(implicit mappingContext: MappingContext): AppProgram[Int] = { val issueConverter = new IssueConverter() val commentConverter = new CommentConverter() @@ -135,13 +136,13 @@ object BacklogExport extends Logger { _ <- AppDSL.consumeStream { todos.zipWithIndex.map { case (todo, index) => - exportTodo(config.backlogPaths, todo.id, issueType, issueConverter, commentConverter, openStatusName, index, count) + exportTodo(config.backlogPaths, todo.id, issueType, issueConverter, commentConverter, openStatusName, startIndex + index, startIndex + count) } } - } yield () + } yield startIndex + count } - def events(config: Config, issueType: CybozuIssueType)(implicit mappingContext: MappingContext): AppProgram[Unit] = { + def events(config: Config, issueType: CybozuIssueType, startIndex: Int)(implicit mappingContext: MappingContext): AppProgram[Int] = { val issueConverter = new IssueConverter() val commentConverter = new CommentConverter() @@ -151,13 +152,13 @@ object BacklogExport extends Logger { _ <- AppDSL.consumeStream { events.zipWithIndex.map { case (event, index) => - exportEvent(config.backlogPaths, event.id, issueType, issueConverter, commentConverter, index, total) + exportEvent(config.backlogPaths, event.id, issueType, issueConverter, commentConverter, startIndex + index, startIndex + total) } } - } yield () + } yield startIndex + total } - def forums(config: Config, issueType: CybozuIssueType)(implicit mappingContext: MappingContext): AppProgram[Unit] = { + def forums(config: Config, issueType: CybozuIssueType, startIndex: Int)(implicit mappingContext: MappingContext): AppProgram[Int] = { val issueConverter = new IssueConverter() val commentConverter = new CommentConverter() @@ -167,10 +168,10 @@ object BacklogExport extends Logger { _ <- AppDSL.consumeStream { forums.zipWithIndex.map { case (forum, index) => - exportForum(config.backlogPaths, forum.id, issueType, issueConverter, commentConverter, index, total) + exportForum(config.backlogPaths, forum.id, issueType, issueConverter, commentConverter, startIndex + index, startIndex + total) } } - } yield () + } yield total } private def exportTodo(paths: BacklogPaths, @@ -183,7 +184,11 @@ object BacklogExport extends Logger { total: Long): AppProgram[Unit] = for { optTodo <- AppDSL.fromStore(StoreDSL.getTodo(Id.todoId(todoId))) - _ <- optTodo.map(todo => + _ <- optTodo.map { todo => + val newId = index.toInt + 1 + val comments = todo.comments.map(c => c.copy(parentId = newId)) + todo.copy(id = newId, comments = comments) + }.map { todo => issueConverter.from(todo, issueType) match { case Right(backlogIssue) => for { @@ -206,7 +211,7 @@ object BacklogExport extends Logger { case Left(error) => throw CybozuLiveImporterException("ToDo convert error. " + error.toString) } - ).getOrElse(throw CybozuLiveImporterException("ToDo not found")) + }.getOrElse(throw CybozuLiveImporterException("ToDo not found")) } yield () private def exportEvent(paths: BacklogPaths, @@ -218,7 +223,11 @@ object BacklogExport extends Logger { total: Long): AppProgram[Unit] = for { optEvent <- AppDSL.fromStore(StoreDSL.getEvent(eventId)) - _ <- optEvent.map(event => + _ <- optEvent.map { event => + val newId = index.toInt + 1 + val comments = event.comments.map(c => c.copy(parentId = newId)) + event.copy(id = newId, comments = comments) + }.map { event => issueConverter.from(event, issueType) match { case Right(backlogIssue) => for { @@ -228,7 +237,7 @@ object BacklogExport extends Logger { case Left(error) => throw CybozuLiveImporterException("Event convert error. " + error.toString) } - ).getOrElse(throw CybozuLiveImporterException("Event not found")) + }.getOrElse(throw CybozuLiveImporterException("Event not found")) } yield () private def exportForum(paths: BacklogPaths, @@ -240,17 +249,22 @@ object BacklogExport extends Logger { total: Long): AppProgram[Unit] = for { optForum <- AppDSL.fromStore(StoreDSL.getForum(forumId)) - _ <- optForum.map(forum => - issueConverter.from(forum, issueType) match { - case Right(backlogIssue) => - for { - _ <- exportIssue(paths, backlogIssue, forum.createdAt, index, total) - _ <- exportComments(paths, forum.comments, commentConverter) - } yield () - case Left(error) => - throw CybozuLiveImporterException("Forum convert error. " + error.toString) - } - ).getOrElse(throw CybozuLiveImporterException("Forum not found")) + _ <- optForum + .map { forum => + val newId = index.toInt + 1 + val comments = forum.comments.map(c => c.copy(parentId = newId)) + forum.copy(id = newId, comments = comments) + }.map { forum => + issueConverter.from(forum.copy(id = index.toInt + 1), issueType) match { + case Right(backlogIssue) => + for { + _ <- exportIssue(paths, backlogIssue, forum.createdAt, index, total) + _ <- exportComments(paths, forum.comments, commentConverter) + } yield () + case Left(error) => + throw CybozuLiveImporterException("Forum convert error. " + error.toString) + } + }.getOrElse(throw CybozuLiveImporterException("Forum not found")) } yield () From b0e2082f8942cbed0270b002fbd1a85c54d6fbc4 Mon Sep 17 00:00:00 2001 From: Shoma Nishitateno Date: Thu, 24 May 2018 15:39:33 +0900 Subject: [PATCH 3/3] Release: 0.1.0b3 --- build.sbt | 2 +- src/main/resources/application.conf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 5688f26..8bd6750 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ name := "backlog-migration-cybozulive" lazy val commonSettings = Seq( - version := "0.1.0b3-SNAPSHOT", + version := "0.1.0b3", scalaVersion := "2.12.6", libraryDependencies ++= Seq( "org.fusesource.jansi" % "jansi" % "1.17", diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 2d625ba..330aa03 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -1,14 +1,14 @@ app { name = "Backlog Migration for CybozuLive" - version = "0.1.0b3-SNAPSHOT" + version = "0.1.0b3" title = ${app.name} ${app.version} (c) nulab.inc fileName = backlog-migration-cybozulive-${app.version}.jar language = default dataDirectory = "./backlog-migration" mixpanel { - token = "6aad3862b3514d664ebb4501f86f42c8" - backlogtoolToken = "6aad3862b3514d664ebb4501f86f42c8" + token = "5be8b628b7103858164142d02cb38347" + backlogtoolToken = "0512c52e553b9283143bed99e61c27e4" product = "cybozulive" } }