mirror of
https://github.com/outline/outline.git
synced 2026-05-02 07:29:41 -05:00
perf: Add missing indexes (#10124)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
/** @type {import('sequelize-cli').Migration} */
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.addIndex("revisions", ["createdAt"], {
|
||||
concurrently: true,
|
||||
});
|
||||
await queryInterface.addIndex("user_permissions", ["sourceId"], {
|
||||
concurrently: true,
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeIndex("user_permissions", ["sourceId"]);
|
||||
await queryInterface.removeIndex("revisions", ["createdAt"]);
|
||||
},
|
||||
};
|
||||
@@ -19,10 +19,15 @@ export default class BacklinksProcessor extends BaseProcessor {
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Note: These can be UUID or slugs
|
||||
const linkIds = DocumentHelper.parseDocumentIds(document);
|
||||
|
||||
await Promise.all(
|
||||
linkIds.map(async (linkId) => {
|
||||
const linkedDocument = await Document.findByPk(linkId);
|
||||
const linkedDocument = await Document.findByPk(linkId, {
|
||||
attributes: ["id"],
|
||||
});
|
||||
|
||||
if (!linkedDocument || linkedDocument.id === event.documentId) {
|
||||
return;
|
||||
@@ -61,7 +66,9 @@ export default class BacklinksProcessor extends BaseProcessor {
|
||||
// create or find existing backlink records for referenced docs
|
||||
await Promise.all(
|
||||
linkIds.map(async (linkId) => {
|
||||
const linkedDocument = await Document.findByPk(linkId);
|
||||
const linkedDocument = await Document.findByPk(linkId, {
|
||||
attributes: ["id"],
|
||||
});
|
||||
|
||||
if (!linkedDocument || linkedDocument.id === event.documentId) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user