[backend] Use more efficient home timeline heuristics query
This commit is contained in:
parent
b9b669570b
commit
7aa3bdb641
1 changed files with 6 additions and 1 deletions
|
@ -23,7 +23,12 @@ export async function generateFollowingQuery(
|
||||||
return Notes.createQueryBuilder('note')
|
return Notes.createQueryBuilder('note')
|
||||||
.where(`note.createdAt > :prev`, { prev })
|
.where(`note.createdAt > :prev`, { prev })
|
||||||
.andWhere(`note.createdAt < :curr`, { curr })
|
.andWhere(`note.createdAt < :curr`, { curr })
|
||||||
.andWhere(`note.userId = ANY(array(${followingQuery.getQuery()} UNION ALL VALUES (:meId)))`, { meId: me.id })
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.where(`note.userId IN (${followingQuery.getQuery()})`);
|
||||||
|
qb.orWhere(`note.userId = :meId`, { meId: me.id });
|
||||||
|
})
|
||||||
|
)
|
||||||
.getCount()
|
.getCount()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
logger.info(`Calculating heuristics for user ${me.id} took ${new Date().getTime() - curr.getTime()}ms`);
|
logger.info(`Calculating heuristics for user ${me.id} took ${new Date().getTime() - curr.getTime()}ms`);
|
||||||
|
|
Loading…
Reference in a new issue