From 1c4967015c8783194d1d4d71b00b61494f966ca9 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 10 Nov 2022 00:38:11 +0100 Subject: [PATCH] server: rewrite skipped instances query in raw SQL --- .../backend/src/misc/skipped-instances.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/misc/skipped-instances.ts b/packages/backend/src/misc/skipped-instances.ts index 3d3d333b8..492d5b6f4 100644 --- a/packages/backend/src/misc/skipped-instances.ts +++ b/packages/backend/src/misc/skipped-instances.ts @@ -1,4 +1,5 @@ import { Brackets } from 'typeorm'; +import { db } from '@/db/postgre.js'; import { fetchMeta } from '@/misc/fetch-meta.js'; import { Instances } from '@/models/index.js'; import { Instance } from '@/models/entities/instance.js'; @@ -25,19 +26,16 @@ export async function skippedInstances(hosts: Array): Array !skipped.includes(host)), - }) - .andWhere(new Brackets(qb => { qb - .where('instance.isSuspended') - .orWhere('instance.lastCommunicatedAt < :deadTime', { deadTime }) - .orWhere('instance.latestStatus = 410'); - })) - .select('host') - .getRawMany() + hosts.filter(host => !skipped.includes(host) && !host.includes(',')).join(','), + ], + ) + .then(res => res.map(row => row.host)) ); }