refactor: Rename function

This commit is contained in:
syuilo 2020-07-28 09:38:41 +09:00
parent a8adc46f3b
commit 1b9d316e7c
18 changed files with 36 additions and 36 deletions

View file

@ -2,7 +2,7 @@ import { User } from '../../../models/entities/user';
import { Mutings } from '../../../models';
import { SelectQueryBuilder, Brackets } from 'typeorm';
export function generateMuteQuery(q: SelectQueryBuilder<any>, me: User, exclude?: User) {
export function generateMutedUserQuery(q: SelectQueryBuilder<any>, me: User, exclude?: User) {
const mutingQuery = Mutings.createQueryBuilder('muting')
.select('muting.muteeId')
.where('muting.muterId = :muterId', { muterId: me.id });
@ -28,7 +28,7 @@ export function generateMuteQuery(q: SelectQueryBuilder<any>, me: User, exclude?
q.setParameters(mutingQuery.getParameters());
}
export function generateMuteQueryForUsers(q: SelectQueryBuilder<any>, me: User) {
export function generateMutedUserQueryForUsers(q: SelectQueryBuilder<any>, me: User) {
const mutingQuery = Mutings.createQueryBuilder('muting')
.select('muting.muteeId')
.where('muting.muterId = :muterId', { muterId: me.id });

View file

@ -2,7 +2,7 @@ import rndstr from 'rndstr';
import { Note } from '../../../models/entities/note';
import { User } from '../../../models/entities/user';
import { Notes, UserProfiles, NoteReactions } from '../../../models';
import { generateMuteQuery } from './generate-mute-query';
import { generateMutedUserQuery } from './generate-muted-user-query';
import { ensure } from '../../../prelude/ensure';
// TODO: リアクション、Renote、返信などをしたートは除外する
@ -29,7 +29,7 @@ export async function injectFeatured(timeline: Note[], user?: User | null) {
if (user) {
query.andWhere('note.userId != :userId', { userId: user.id });
generateMuteQuery(query, user);
generateMutedUserQuery(query, user);
const reactionQuery = NoteReactions.createQueryBuilder('reaction')
.select('reaction.noteId')

View file

@ -4,7 +4,7 @@ import define from '../../define';
import { Antennas, Notes, AntennaNotes } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { ApiError } from '../../error';
export const meta = {
@ -62,7 +62,7 @@ export default define(meta, async (ps, user) => {
.setParameters(antennaQuery.getParameters());
generateVisibilityQuery(query, user);
generateMuteQuery(query, user);
generateMutedUserQuery(query, user);
const notes = await query
.take(ps.limit!)

View file

@ -4,7 +4,7 @@ import define from '../../define';
import { Clips, Notes } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
export const meta = {
tags: ['account', 'notes', 'clips'],
@ -57,7 +57,7 @@ export default define(meta, async (ps, user) => {
.setParameters(clipQuery.getParameters());
generateVisibilityQuery(query, user);
generateMuteQuery(query, user);
generateMutedUserQuery(query, user);
const notes = await query
.take(ps.limit!)

View file

@ -3,7 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { Brackets } from 'typeorm';
import { Notes } from '../../../../models';
@ -67,7 +67,7 @@ export default define(meta, async (ps, user) => {
.leftJoinAndSelect('note.user', 'user');
generateVisibilityQuery(query, user);
if (user) generateMuteQuery(query, user);
if (user) generateMutedUserQuery(query, user);
const notes = await query.take(ps.limit!).getMany();

View file

@ -1,6 +1,6 @@
import $ from 'cafy';
import define from '../../define';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { Notes } from '../../../../models';
export const meta = {
@ -51,7 +51,7 @@ export default define(meta, async (ps, user) => {
.andWhere(`note.visibility = 'public'`)
.leftJoinAndSelect('note.user', 'user');
if (user) generateMuteQuery(query, user);
if (user) generateMutedUserQuery(query, user);
let notes = await query
.orderBy('note.score', 'DESC')

View file

@ -5,7 +5,7 @@ import { fetchMeta } from '../../../../misc/fetch-meta';
import { ApiError } from '../../error';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notes } from '../../../../models';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { activeUsersChart } from '../../../../services/chart';
import { generateRepliesQuery } from '../../common/generate-replies-query';
import { injectPromo } from '../../common/inject-promo';
@ -83,7 +83,7 @@ export default define(meta, async (ps, user) => {
.leftJoinAndSelect('note.user', 'user');
generateRepliesQuery(query, user);
if (user) generateMuteQuery(query, user);
if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user);
if (ps.withFiles) {

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
import { Followings, Notes } from '../../../../models';
import { Brackets } from 'typeorm';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { activeUsersChart } from '../../../../services/chart';
import { generateRepliesQuery } from '../../common/generate-replies-query';
import { injectPromo } from '../../common/inject-promo';
@ -133,7 +133,7 @@ export default define(meta, async (ps, user) => {
generateRepliesQuery(query, user);
generateVisibilityQuery(query, user);
generateMuteQuery(query, user);
generateMutedUserQuery(query, user);
generateMutedNoteQuery(query, user);
if (ps.includeMyRenotes === false) {

View file

@ -4,7 +4,7 @@ import define from '../../define';
import { fetchMeta } from '../../../../misc/fetch-meta';
import { ApiError } from '../../error';
import { Notes } from '../../../../models';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { activeUsersChart } from '../../../../services/chart';
@ -101,7 +101,7 @@ export default define(meta, async (ps, user) => {
generateRepliesQuery(query, user);
generateVisibilityQuery(query, user);
if (user) generateMuteQuery(query, user);
if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user);
if (ps.withFiles) {

View file

@ -4,7 +4,7 @@ import define from '../../define';
import read from '../../../../services/note/read';
import { Notes, Followings } from '../../../../models';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Brackets } from 'typeorm';
@ -66,7 +66,7 @@ export default define(meta, async (ps, user) => {
.leftJoinAndSelect('note.user', 'user');
generateVisibilityQuery(query, user);
generateMuteQuery(query, user);
generateMutedUserQuery(query, user);
if (ps.visibility) {
query.andWhere('note.visibility = :visibility', { visibility: ps.visibility });

View file

@ -4,7 +4,7 @@ import define from '../../define';
import { getNote } from '../../common/getters';
import { ApiError } from '../../error';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notes } from '../../../../models';
@ -71,7 +71,7 @@ export default define(meta, async (ps, user) => {
.leftJoinAndSelect('note.user', 'user');
generateVisibilityQuery(query, user);
if (user) generateMuteQuery(query, user);
if (user) generateMutedUserQuery(query, user);
const renotes = await query.take(ps.limit!).getMany();

View file

@ -4,7 +4,7 @@ import define from '../../define';
import { Notes } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
export const meta = {
desc: {
@ -62,7 +62,7 @@ export default define(meta, async (ps, user) => {
.leftJoinAndSelect('note.user', 'user');
generateVisibilityQuery(query, user);
if (user) generateMuteQuery(query, user);
if (user) generateMutedUserQuery(query, user);
const timeline = await query.take(ps.limit!).getMany();

View file

@ -3,7 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notes } from '../../../../models';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { Brackets } from 'typeorm';
import { safeForSql } from '../../../../misc/safe-for-sql';
@ -97,7 +97,7 @@ export default define(meta, async (ps, me) => {
.leftJoinAndSelect('note.user', 'user');
generateVisibilityQuery(query, me);
if (me) generateMuteQuery(query, me);
if (me) generateMutedUserQuery(query, me);
if (ps.tag) {
if (!safeForSql(ps.tag)) return;

View file

@ -7,7 +7,7 @@ import { ID } from '../../../../misc/cafy-id';
import config from '../../../../config';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
export const meta = {
desc: {
@ -69,7 +69,7 @@ export default define(meta, async (ps, me) => {
.leftJoinAndSelect('note.user', 'user');
generateVisibilityQuery(query, me);
if (me) generateMuteQuery(query, me);
if (me) generateMutedUserQuery(query, me);
const notes = await query.take(ps.limit!).getMany();

View file

@ -4,7 +4,7 @@ import define from '../../define';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notes, Followings } from '../../../../models';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { activeUsersChart } from '../../../../services/chart';
import { Brackets } from 'typeorm';
import { generateRepliesQuery } from '../../common/generate-replies-query';
@ -126,7 +126,7 @@ export default define(meta, async (ps, user) => {
generateRepliesQuery(query, user);
generateVisibilityQuery(query, user);
generateMuteQuery(query, user);
generateMutedUserQuery(query, user);
generateMutedNoteQuery(query, user);
if (ps.includeMyRenotes === false) {

View file

@ -1,7 +1,7 @@
import $ from 'cafy';
import define from '../define';
import { Users } from '../../../models';
import { generateMuteQueryForUsers } from '../common/generate-mute-query';
import { generateMutedUserQueryForUsers } from '../common/generate-muted-user-query';
export const meta = {
tags: ['users'],
@ -87,7 +87,7 @@ export default define(meta, async (ps, me) => {
default: query.orderBy('user.id', 'ASC'); break;
}
if (me) generateMuteQueryForUsers(query, me);
if (me) generateMutedUserQueryForUsers(query, me);
query.take(ps.limit!);
query.skip(ps.offset);

View file

@ -6,7 +6,7 @@ import { getUser } from '../../common/getters';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { Notes } from '../../../../models';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { Brackets } from 'typeorm';
export const meta = {
@ -134,7 +134,7 @@ export default define(meta, async (ps, me) => {
.leftJoinAndSelect('note.user', 'user');
generateVisibilityQuery(query, me);
if (me) generateMuteQuery(query, me, user);
if (me) generateMutedUserQuery(query, me, user);
if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');

View file

@ -2,7 +2,7 @@ import * as ms from 'ms';
import $ from 'cafy';
import define from '../../define';
import { Users, Followings } from '../../../../models';
import { generateMuteQueryForUsers } from '../../common/generate-mute-query';
import { generateMutedUserQueryForUsers } from '../../common/generate-muted-user-query';
import { generateBlockQueryForUsers } from '../../common/generate-block-query';
export const meta = {
@ -47,7 +47,7 @@ export default define(meta, async (ps, me) => {
.andWhere('user.id != :meId', { meId: me.id })
.orderBy('user.followersCount', 'DESC');
generateMuteQueryForUsers(query, me);
generateMutedUserQueryForUsers(query, me);
generateBlockQueryForUsers(query, me);
const followingQuery = Followings.createQueryBuilder('following')