From 5b9e2ec8170ae9dd15321cb231d9973b3e369925 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 29 Jul 2022 09:17:10 -0700 Subject: [PATCH] try new query --- .../api/endpoints/notes/recommended-timeline.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts index e89f8db3f..923e9bb86 100644 --- a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts @@ -1,6 +1,6 @@ import { Brackets } from 'typeorm'; import { fetchMeta } from '@/misc/fetch-meta.js'; -import { Notes, Users } from '@/models/index.js'; +import { Notes, Metas } from '@/models/index.js'; import { activeUsersChart } from '@/services/chart/index.js'; import define from '../../define.js'; import { ApiError } from '../../error.js'; @@ -66,12 +66,17 @@ export default define(meta, paramDef, async (ps, user) => { } // .andWhere('(note.userHost IN (:instances)) OR (note.userHost IS NULL)', { instances: instances }) + //#region Construct query + const instancesQuery = Metas.createQueryBuilder('meta') + .select('meta.recommendedInstances'); + // .where('meta.recommendedInstances = ANY(:instance)', { instance: m.recommendedInstances }); + const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) .andWhere(new Brackets(qb => { - qb.where('note.userHost IN (:instances)', { instances: m.recommendedInstances }) - .orWhere('note.userHost IS NULL'); + qb.where(`note.userHost IN ${ instancesQuery.getQuery() }`); + // .orWhere('note.userHost IS NULL'); })) .andWhere('(note.visibility = \'public\')') .innerJoinAndSelect('note.user', 'user')