fix(backend): incorrect typing with query

This commit is contained in:
Sayamame-beans 2024-11-19 13:11:33 +00:00
parent 590d5dd0bf
commit 597412abcc
1 changed files with 7 additions and 1 deletions

View File

@ -132,8 +132,13 @@ export class QueryService {
.select('muting.muteeId') .select('muting.muteeId')
.where('muting.muterId = :muterId', { muterId: me.id }); .where('muting.muterId = :muterId', { muterId: me.id });
const mutingArrayQuery = this.mutingsRepository.createQueryBuilder('muting')
.select('array_agg(muting.muteeId)', 'muting.muteeIdArray')
.where('muting.muterId = :muterId', { muterId: me.id });
if (exclude) { if (exclude) {
mutingQuery.andWhere('muting.muteeId != :excludeId', { excludeId: exclude.id }); mutingQuery.andWhere('muting.muteeId != :excludeId', { excludeId: exclude.id });
mutingArrayQuery.andWhere('muting.muteeId != :excludeId', { excludeId: exclude.id });
} }
const mutingInstanceQuery = this.userProfilesRepository.createQueryBuilder('user_profile') const mutingInstanceQuery = this.userProfilesRepository.createQueryBuilder('user_profile')
@ -177,11 +182,12 @@ export class QueryService {
q.andWhere(new Brackets(qb => { q.andWhere(new Brackets(qb => {
qb qb
.where('note.mentions IS NULL') .where('note.mentions IS NULL')
.orWhere(`NOT (note.mentions && (${ mutingQuery.getQuery() }))`); .orWhere(`NOT (note.mentions && (${ mutingArrayQuery.getQuery() }))`);
})); }));
} }
q.setParameters(mutingQuery.getParameters()); q.setParameters(mutingQuery.getParameters());
q.setParameters(mutingArrayQuery.getParameters());
q.setParameters(mutingInstanceQuery.getParameters()); q.setParameters(mutingInstanceQuery.getParameters());
} }