Skip to content

Commit

Permalink
fixed broken updates for pages (and probably pieces depending on the …
Browse files Browse the repository at this point in the history
…situation)
  • Loading branch information
boutell committed Sep 5, 2024
1 parent 60459fb commit ed8d8ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
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
39 changes: 21 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,26 @@ 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;
}
}

self.isPage(manager)
? await importPage.update({
self.apos.schema.simulateRelationshipsFromStorage(req, doc, manager.schema);
// One of these must work else we would not be updating. The id match is preferable
// don't just use $or
const docToUpdate = await self.apos.doc.db.findOne({ _id: doc._id }) || await self.apos.doc.db.findOne({ aposLocale: doc.aposLocale, aposDocId: doc.aposDocId });

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 4.4)

Expected a line break after this opening brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 4.4)

Object properties must go on a new line

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 4.4)

Expected a line break before this closing brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 5.0)

Expected a line break after this opening brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 5.0)

Object properties must go on a new line

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 5.0)

Expected a line break before this closing brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 6.0)

Expected a line break after this opening brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 6.0)

Object properties must go on a new line

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (18, 6.0)

Expected a line break before this closing brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 4.4)

Expected a line break after this opening brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 4.4)

Object properties must go on a new line

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 4.4)

Expected a line break before this closing brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

Expected a line break after this opening brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

Object properties must go on a new line

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 5.0)

Expected a line break before this closing brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 6.0)

Expected a line break after this opening brace

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 6.0)

Object properties must go on a new line

Check warning on line 672 in lib/methods/import.js

View workflow job for this annotation

GitHub Actions / build (20, 6.0)

Expected a line break before this closing brace
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

0 comments on commit ed8d8ff

Please sign in to comment.