chore: Various importer improvements (#6519)

* Handle new Notion export format
Clear data on file operation delete

* fix: Don't restart development server on html upload

* fix: Do not send collection created notifications on bulk import

* fix: Avoid parellelizing all uploads at once
Move import into one transaction per-collection
This commit is contained in:
Tom Moor
2024-02-10 12:21:52 -08:00
committed by GitHub
parent e608de93fb
commit 012d8c2ae7
8 changed files with 198 additions and 302 deletions

View File

@@ -1006,22 +1006,25 @@ class Document extends ParanoidModel<
toNavigationNode = async (
options?: FindOptions<Document>
): Promise<NavigationNode> => {
const childDocuments = await (this.constructor as typeof Document)
.unscoped()
.scope("withoutState")
.findAll({
where: {
teamId: this.teamId,
parentDocumentId: this.id,
archivedAt: {
[Op.is]: null,
},
publishedAt: {
[Op.ne]: null,
},
},
transaction: options?.transaction,
});
// Checking if the record is new is a performance optimization new docs cannot have children
const childDocuments = this.isNewRecord
? []
: await (this.constructor as typeof Document)
.unscoped()
.scope("withoutState")
.findAll({
where: {
teamId: this.teamId,
parentDocumentId: this.id,
archivedAt: {
[Op.is]: null,
},
publishedAt: {
[Op.ne]: null,
},
},
transaction: options?.transaction,
});
const children = await Promise.all(
childDocuments.map((child) => child.toNavigationNode(options))