From c917c9df545232c003a28e56f6f7e41c2eef85a5 Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Sun, 9 Jan 2022 01:51:11 +0200 Subject: [PATCH] Fork correctly --- server/router/fork/index.js | 60 ++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/server/router/fork/index.js b/server/router/fork/index.js index ea01e62..877c2ea 100644 --- a/server/router/fork/index.js +++ b/server/router/fork/index.js @@ -148,6 +148,14 @@ module.exports = function (options) { where: { dialectId: dialect.id, } + }, + { + association: db.ArtifactVersion.Chapters, + include: [ + { + association: db.Chapter.Chunks + } + ] } ] }) @@ -183,7 +191,21 @@ module.exports = function (options) { entityId: entityId, } ] - } + }, + translationChapters: artifactVersion.chapters.map(chapter => { + return { + creatorId: userId, + chapterId: chapter.id, + translationChunks: chapter.chunks.map(chunk => { + return { + creatorId: userId, + chunkId: chunk.id, + text: chunk.text, + index: chunk.index + } + }) + } + }) }, { include: [ { @@ -193,7 +215,15 @@ module.exports = function (options) { association: db.Owner.OwnerEntities } ] - } + }, + { + association: db.TranslationArtifactVersion.TranslationChapters, + include: [ + { + association: db.TranslationChapter.TranslationChunks + } + ] + }, ] }) } else { @@ -210,7 +240,21 @@ module.exports = function (options) { entityId: entityId, } ] - } + }, + translationChapters: artifactVersion.chapters.map(chapter => { + return { + creatorId: userId, + chapterId: chapter.id, + translationChunks: chapter.chunks.map(chunk => { + return { + creatorId: userId, + chunkId: chunk.id, + text: chunk.text, + index: chunk.index + } + }) + } + }) }, { include: [ { @@ -220,7 +264,15 @@ module.exports = function (options) { association: db.Owner.OwnerEntities } ] - } + }, + { + association: db.TranslationArtifactVersion.TranslationChapters, + include: [ + { + association: db.TranslationChapter.TranslationChunks + } + ] + }, ] }) }