1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-11-28 14:58:15 +09:00

Revert "fix(server): Use inner join"

This reverts commit d7e7848c92.
This commit is contained in:
syuilo 2021-03-21 12:31:56 +09:00
parent e987a50e9f
commit c52b504140
19 changed files with 91 additions and 91 deletions

View File

@ -23,7 +23,7 @@ export async function injectFeatured(timeline: Note[], user?: User | null) {
.andWhere(`note.score > 0`)
.andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) })
.andWhere(`note.visibility = 'public'`)
.innerJoinAndSelect('note.user', 'user');
.leftJoinAndSelect('note.user', 'user');
if (user) {
query.andWhere('note.userId != :userId', { userId: user.id });

View File

@ -73,11 +73,11 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.id IN (${ antennaQuery.getQuery() })`)
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser')
.setParameters(antennaQuery.getParameters());
generateVisibilityQuery(query, user);

View File

@ -87,11 +87,11 @@ export default define(meta, async (ps, user) => {
//#region Construct query
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('note.channelId = :channelId', { channelId: channel.id })
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.channel', 'channel');
//#endregion

View File

@ -71,11 +71,11 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.id IN (${ clipQuery.getQuery() })`)
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser')
.setParameters(clipQuery.getParameters());
if (user) {

View File

@ -87,11 +87,11 @@ export default define(meta, async (ps, user) => {
.andWhere(`notification.notifieeId = :meId`, { meId: user.id })
.leftJoinAndSelect('notification.notifier', 'notifier')
.leftJoinAndSelect('notification.note', 'note')
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
query.andWhere(`notification.notifierId NOT IN (${ mutingQuery.getQuery() })`);
query.setParameters(mutingQuery.getParameters());

View File

@ -76,11 +76,11 @@ export default define(meta, async (ps) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.visibility = 'public'`)
.andWhere(`note.localOnly = FALSE`)
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
if (ps.local) {
query.andWhere('note.userHost IS NULL');

View File

@ -64,11 +64,11 @@ export default define(meta, async (ps, user) => {
}));
}));
}))
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user);

View File

@ -49,11 +49,11 @@ export default define(meta, async (ps, user) => {
.andWhere(`note.score > 0`)
.andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) })
.andWhere(`note.visibility = 'public'`)
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
if (user) generateMutedUserQuery(query, user);

View File

@ -79,11 +79,11 @@ export default define(meta, async (ps, user) => {
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('note.visibility = \'public\'')
.andWhere('note.channelId IS NULL')
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateRepliesQuery(query, user);
if (user) generateMutedUserQuery(query, user);

View File

@ -127,11 +127,11 @@ export default define(meta, async (ps, user) => {
qb.where(`((note.userId IN (${ followingQuery.getQuery() })) OR (note.userId = :meId))`, { meId: user.id })
.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)');
}))
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser')
.setParameters(followingQuery.getParameters());
generateChannelQuery(query, user);

View File

@ -96,11 +96,11 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)')
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateChannelQuery(query, user);
generateRepliesQuery(query, user);

View File

@ -63,11 +63,11 @@ export default define(meta, async (ps, user) => {
.where(`:meId = ANY(note.mentions)`, { meId: user.id })
.orWhere(`:meId = ANY(note.visibleUserIds)`, { meId: user.id });
}))
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user);

View File

@ -68,11 +68,11 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.renoteId = :renoteId`, { renoteId: note.id })
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user);

View File

@ -59,11 +59,11 @@ export const meta = {
export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere('note.replyId = :replyId', { replyId: ps.noteId })
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user);

View File

@ -95,11 +95,11 @@ export const meta = {
export default define(meta, async (ps, me) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateVisibilityQuery(query, me);
if (me) generateMutedUserQuery(query, me);

View File

@ -79,11 +79,11 @@ export default define(meta, async (ps, me) => {
query
.andWhere('note.text ILIKE :q', { q: `%${ps.query}%` })
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateVisibilityQuery(query, me);
if (me) generateMutedUserQuery(query, me);

View File

@ -120,11 +120,11 @@ export default define(meta, async (ps, user) => {
.where('note.userId = :meId', { meId: user.id });
if (hasFollowing) qb.orWhere(`note.userId IN (${ followingQuery.getQuery() })`);
}))
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser')
.setParameters(followingQuery.getParameters());
generateChannelQuery(query, user);

View File

@ -130,11 +130,11 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.userId IN (${ listQuery.getQuery() })`)
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser')
.setParameters(listQuery.getParameters());
generateVisibilityQuery(query, user);

View File

@ -131,11 +131,11 @@ export default define(meta, async (ps, me) => {
//#region Construct query
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('note.userId = :userId', { userId: user.id })
.innerJoinAndSelect('note.user', 'user')
.innerJoinAndSelect('note.reply', 'reply')
.innerJoinAndSelect('note.renote', 'renote')
.innerJoinAndSelect('reply.user', 'replyUser')
.innerJoinAndSelect('renote.user', 'renoteUser');
.leftJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
generateVisibilityQuery(query, me);
if (me) generateMutedUserQuery(query, me, user);