Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the broken parked page imports #82

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/methods/import-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const update = async ({
req,
duplicatedDocs
}) => {

const {
_id,
aposDocId,
Expand Down
37 changes: 19 additions & 18 deletions lib/methods/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,10 @@ module.exports = self => {
for (const docToUpdate of docsToUpdate) {
const _req = req.clone({ mode: docToUpdate.aposMode });

await manager.convert(_req, doc, docToUpdate, { presentFieldsOnly: true });
await manager.convert(_req, doc, docToUpdate, {
presentFieldsOnly: true,
fetchRelationships: false
});
self.isPage(manager)
? await importPage.update({
manager: self.apos.page,
Expand Down Expand Up @@ -638,6 +641,7 @@ module.exports = self => {

const type = doc.type;
const docToInsert = doc;

await manager.convert(_req, doc, docToInsert, {
presentFieldsOnly: true,
fetchRelationships: false
Expand All @@ -662,27 +666,24 @@ module.exports = self => {

async function update() {
const _req = req.clone({ mode: doc.aposMode });

if (doc.aposMode === 'draft') {
const existingDoc = await self.apos.doc.db.findOne({ _id: doc._id }, {
lastPublishedAt: 1
});
if (existingDoc) {
doc.lastPublishedAt = existingDoc.lastPublishedAt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was the lastPublishedAt thing important?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's going to get that automatically because we always start with the actual doc as found in the database and apply convert to update properties actually present in the imported doc and the schema, which will leave lastPublishedAt unchanged

}
}

self.isPage(manager)
? await importPage.update({
self.apos.schema.simulateRelationshipsFromStorage(req, doc, manager.schema);
const docToUpdate = await self.apos.doc.db.findOne({ _id: doc._id });
await manager.convert(_req, doc, docToUpdate, {
presentFieldsOnly: true,
fetchRelationships: false
});
if (self.isPage(manager)) {
await importPage.update({
manager: self.apos.page,
doc,
doc: docToUpdate,
req: _req,
duplicatedDocs
})
: await manager.update(_req, doc);

});
} else {
await manager.update(_req, docToUpdate);
}
if (doc.aposMode === 'draft') {
await self.setDocAsNotModified(doc);
await self.setDocAsNotModified(docToUpdate);
}
}
},
Expand Down
Loading