Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

Commit

Permalink
1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Fi1osof committed Dec 29, 2018
1 parent fd36000 commit 59bd6fd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.3.3
===============================
- Fix import comments

1.3.2
===============================
- Update @prisma-cms/module-boilerplate
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
20 changes: 14 additions & 6 deletions src/modules/processor/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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", [
Expand All @@ -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",
Expand Down Expand Up @@ -857,7 +863,7 @@ export default class ImportProcessor extends PrismaProcessor {

let {
id,
oldID,
commentOldID,
// pagetitle: name,
createdon,
editedon,
Expand All @@ -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,
Expand All @@ -899,7 +907,7 @@ export default class ImportProcessor extends PrismaProcessor {
result = await db.mutation.createResource({
data: {
type,
oldID: id,
commentOldID,
class_key,
template,
uri,
Expand Down
1 change: 1 addition & 0 deletions src/modules/schema/database/resource.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 59bd6fd

Please sign in to comment.