From d9ec53db4cd3fe3f416bb57650f2d63db7ad84e0 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 25 Sep 2023 22:48:16 +0200 Subject: [PATCH] [mastodon-client] Further improve query performance --- packages/backend/src/server/api/mastodon/converters/note.ts | 3 +-- packages/backend/src/server/api/mastodon/helpers/timeline.ts | 2 -- packages/backend/src/server/api/mastodon/helpers/user.ts | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/converters/note.ts b/packages/backend/src/server/api/mastodon/converters/note.ts index e3c790e6d..5ff76ea40 100644 --- a/packages/backend/src/server/api/mastodon/converters/note.ts +++ b/packages/backend/src/server/api/mastodon/converters/note.ts @@ -53,7 +53,6 @@ export class NoteConverter { } }) : null; - const reply = note.reply ?? (note.replyId ? getNote(note.replyId, user) : null); const renote = note.renote ?? (note.renoteId ? getNote(note.renoteId, user) : null); const isBookmarked = user ? NoteFavorites.exist({ @@ -92,7 +91,7 @@ export class NoteConverter { url: note.uri ? note.uri : `https://${config.host}/notes/${note.id}`, account: Promise.resolve(noteUser).then(p => UserConverter.encode(p, cache)), in_reply_to_id: note.replyId, - in_reply_to_account_id: Promise.resolve(reply).then(reply => reply?.userId ?? null), + in_reply_to_account_id: note.replyUserId, reblog: Promise.resolve(renote).then(renote => renote && note.text === null ? this.encode(renote, user, cache) : null), content: Promise.resolve(text).then(text => text !== null ? toHtml(mfm.parse(text), JSON.parse(note.mentionedRemoteUsers)) ?? escapeMFM(text) : ""), text: text, diff --git a/packages/backend/src/server/api/mastodon/helpers/timeline.ts b/packages/backend/src/server/api/mastodon/helpers/timeline.ts index c867e2ecd..3d779d868 100644 --- a/packages/backend/src/server/api/mastodon/helpers/timeline.ts +++ b/packages/backend/src/server/api/mastodon/helpers/timeline.ts @@ -34,7 +34,6 @@ export class TimelineHelpers { qb.orWhere(`note.userId IN (:...followingIds)`, {followingIds: followingIds}); }), ) - .leftJoinAndSelect("note.reply", "reply") .leftJoinAndSelect("note.renote", "renote"); generateChannelQuery(query, user); @@ -77,7 +76,6 @@ export class TimelineHelpers { if (!local) query.andWhere("note.channelId IS NULL"); query - .leftJoinAndSelect("note.reply", "reply") .leftJoinAndSelect("note.renote", "renote"); generateRepliesQuery(query, true, user); diff --git a/packages/backend/src/server/api/mastodon/helpers/user.ts b/packages/backend/src/server/api/mastodon/helpers/user.ts index ff85541d3..0953701af 100644 --- a/packages/backend/src/server/api/mastodon/helpers/user.ts +++ b/packages/backend/src/server/api/mastodon/helpers/user.ts @@ -51,7 +51,6 @@ export class UserHelpers { if (excludeReblogs) query.andWhere("(note.renoteId IS NOT NULL) OR (note.text IS NOT NULL)"); query - .leftJoinAndSelect("note.reply", "reply") .leftJoinAndSelect("note.renote", "renote"); //FIXME this doesn't exclude replies to your own reply to someone else's post