From 59bd6fd1c651a73c304598c8828d0a5894e5c1c4 Mon Sep 17 00:00:00 2001 From: Fi1osof Date: Sat, 29 Dec 2018 07:34:11 +0300 Subject: [PATCH] 1.3.3 --- changelog.md | 4 ++++ package.json | 2 +- src/modules/processor/index.mjs | 20 ++++++++++++++------ src/modules/schema/database/resource.graphql | 1 + 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index ff8748b..58400a6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +1.3.3 +=============================== +- Fix import comments + 1.3.2 =============================== - Update @prisma-cms/module-boilerplate diff --git a/package.json b/package.json index 2e8f4a2..d67adf5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@modxclub/import-old-site", "description": "Importer for modxclub.ru", - "version": "1.3.2", + "version": "1.3.3", "main": "src/", "files": [ "src" diff --git a/src/modules/processor/index.mjs b/src/modules/processor/index.mjs index 984482c..4f97031 100644 --- a/src/modules/processor/index.mjs +++ b/src/modules/processor/index.mjs @@ -785,8 +785,14 @@ export default class ImportProcessor extends PrismaProcessor { const query = source.getQuery("society_comments", "source") ; + /** + * Ранее была допущена логическая ошибка при импорте комментариев, так как oldID - это id документа, + * а комментарии импортировались из другой таблицы. + * Надо добавить commentOldID и по нему проверять (но при этом учесть ранее импортированные комментарии). + */ query - .leftJoin(target.getTableName("Resource", "target"), "target.oldID", "source.id") + .leftJoin(target.getTableName("Resource", "target"), "target.commentOldID", "source.id") + // .leftJoin(target.getTableName("Resource", "Comment"), "target.commentOldID", "source.id") .innerJoin(target.getTableName("User"), "User.oldID", "source.createdby") .whereNull("target.id") // .whereIn("template", [ @@ -801,12 +807,12 @@ export default class ImportProcessor extends PrismaProcessor { .innerJoin(target.getTableName("Resource", "Topic"), "Topic.oldID", "threads.target_id") query - .leftJoin(target.getTableName("Resource", "Parent"), "Parent.oldID", "source.parent") + .leftJoin(target.getTableName("Resource", "Parent"), "Parent.commentOldID", "source.parent") query.select([ "source.*", - "source.id as oldID", + "source.id as commentOldID", "target_id as topicId", "Topic.name as topicName", "Parent.id as parentId", @@ -857,7 +863,7 @@ export default class ImportProcessor extends PrismaProcessor { let { id, - oldID, + commentOldID, // pagetitle: name, createdon, editedon, @@ -878,7 +884,9 @@ export default class ImportProcessor extends PrismaProcessor { let type = "Comment"; - const uri = `/comments/comment-${oldID}.html`; + editedon = editedon || createdon || undefined; + + const uri = `/comments/comment-${commentOldID}.html`; let { content, @@ -899,7 +907,7 @@ export default class ImportProcessor extends PrismaProcessor { result = await db.mutation.createResource({ data: { type, - oldID: id, + commentOldID, class_key, template, uri, diff --git a/src/modules/schema/database/resource.graphql b/src/modules/schema/database/resource.graphql index b59be26..199942f 100644 --- a/src/modules/schema/database/resource.graphql +++ b/src/modules/schema/database/resource.graphql @@ -2,6 +2,7 @@ type Resource { id: ID! @unique oldID: Int @unique + commentOldID: Int @unique Topics: [Resource!]! @relation(name: "BlogTopics") Blog: Resource @relation(name: "BlogTopics") Service: Service @relation(name: "ServiceResource")