perf: add option to skip querying skilla
This commit is contained in:
parent
e115fed0db
commit
0da215aa7d
4 changed files with 15 additions and 7 deletions
|
@ -137,8 +137,7 @@ export const NoteRepository = db.getRepository(Note).extend({
|
|||
Users.findOneByOrFail({ id: meId }),
|
||||
);
|
||||
|
||||
if (!user.host) {
|
||||
// user is local
|
||||
if (Users.isLocalUser(user)) {
|
||||
const cache = await LocalFollowingsCache.init(meId);
|
||||
return await cache.isFollowing(note.userId);
|
||||
}
|
||||
|
@ -169,6 +168,7 @@ export const NoteRepository = db.getRepository(Note).extend({
|
|||
me?: { id: User["id"] } | null | undefined,
|
||||
options?: {
|
||||
detail?: boolean;
|
||||
scyllaNote?: boolean;
|
||||
_hint_?: {
|
||||
myReactions: Map<Note["id"], NoteReaction | null>;
|
||||
};
|
||||
|
@ -187,7 +187,7 @@ export const NoteRepository = db.getRepository(Note).extend({
|
|||
const isSrcNote = typeof src === "object";
|
||||
|
||||
// Always lookup from ScyllaDB if enabled
|
||||
if (isSrcNote && !scyllaClient) {
|
||||
if (isSrcNote && (!scyllaClient || options?.scyllaNote)) {
|
||||
note = src;
|
||||
} else {
|
||||
const noteId = isSrcNote ? src.id : src;
|
||||
|
@ -346,6 +346,7 @@ export const NoteRepository = db.getRepository(Note).extend({
|
|||
me?: { id: User["id"] } | null | undefined,
|
||||
options?: {
|
||||
detail?: boolean;
|
||||
scyllaNote?: boolean;
|
||||
},
|
||||
) {
|
||||
if (notes.length === 0) return [];
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
export async function getNote(
|
||||
noteId: Note["id"],
|
||||
me: { id: User["id"] } | null,
|
||||
followingIds?: User["id"][]
|
||||
followingIds?: User["id"][],
|
||||
) {
|
||||
let note: Note | null = null;
|
||||
if (scyllaClient) {
|
||||
|
@ -32,7 +32,10 @@ export async function getNote(
|
|||
note = filtered[0];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
// Fallback to Postgres
|
||||
if (!note) {
|
||||
const query = Notes.createQueryBuilder("note").where("note.id = :id", {
|
||||
id: noteId,
|
||||
});
|
||||
|
|
|
@ -67,7 +67,9 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
};
|
||||
|
||||
const foundNotes = await execTimelineQuery(ps, filter);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
||||
scyllaNote: true,
|
||||
});
|
||||
}
|
||||
|
||||
const query = makePaginationQuery(
|
||||
|
|
|
@ -90,7 +90,9 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
};
|
||||
|
||||
const foundNotes = await execTimelineQuery(ps, filter);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
||||
scyllaNote: true,
|
||||
});
|
||||
}
|
||||
|
||||
const hasFollowing = await followingsCache.hasFollowing();
|
||||
|
|
Loading…
Reference in a new issue