perf(server): Reduce database query
This commit is contained in:
@ -8,7 +8,7 @@ import { convertLegacyReaction, convertLegacyReactions, decodeReaction } from '.
|
||||
import { toString } from '../../mfm/to-string';
|
||||
import { parse } from '../../mfm/parse';
|
||||
import { NoteReaction } from '../entities/note-reaction';
|
||||
import { populateEmojis } from '../../misc/populate-emojis';
|
||||
import { aggregateNoteEmojis, populateEmojis, prefetchEmojis } from '../../misc/populate-emojis';
|
||||
|
||||
export type PackedNote = SchemaType<typeof packedNoteSchema>;
|
||||
|
||||
@ -259,6 +259,8 @@ export class NoteRepository extends Repository<Note> {
|
||||
}
|
||||
}
|
||||
|
||||
await prefetchEmojis(aggregateNoteEmojis(notes));
|
||||
|
||||
return await Promise.all(notes.map(n => this.pack(n, me, {
|
||||
...options,
|
||||
_hint_: {
|
||||
|
@ -6,6 +6,7 @@ import { SchemaType } from '../../misc/schema';
|
||||
import { Note } from '../entities/note';
|
||||
import { NoteReaction } from '../entities/note-reaction';
|
||||
import { User } from '../entities/user';
|
||||
import { aggregateNoteEmojis, prefetchEmojis } from '../../misc/populate-emojis';
|
||||
|
||||
export type PackedNotification = SchemaType<typeof packedNotificationSchema>;
|
||||
|
||||
@ -98,6 +99,8 @@ export class NotificationRepository extends Repository<Notification> {
|
||||
myReactionsMap.set(target, myReactions.find(reaction => reaction.noteId === target) || null);
|
||||
}
|
||||
|
||||
await prefetchEmojis(aggregateNoteEmojis(notes));
|
||||
|
||||
return await Promise.all(notifications.map(x => this.pack(x, {
|
||||
_hintForEachNotes_: {
|
||||
myReactions: myReactionsMap
|
||||
|
Reference in New Issue
Block a user