Add erase function (#2641)
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import Note from '../../../../models/note';
|
||||
import { erase } from '../../../../prelude/array';
|
||||
|
||||
/*
|
||||
トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要
|
||||
@ -85,8 +86,7 @@ export default () => new Promise(async (res, rej) => {
|
||||
//#endregion
|
||||
|
||||
// タグを人気順に並べ替え
|
||||
let hots = (await Promise.all(hotsPromises))
|
||||
.filter(x => x != null)
|
||||
let hots = erase(null, await Promise.all(hotsPromises))
|
||||
.sort((a, b) => b.count - a.count)
|
||||
.map(tag => tag.name)
|
||||
.slice(0, max);
|
||||
|
@ -5,6 +5,7 @@ import Mute from '../../../../models/mute';
|
||||
import { getFriendIds } from '../../common/get-friends';
|
||||
import { pack } from '../../../../models/note';
|
||||
import getParams from '../../get-params';
|
||||
import { erase } from '../../../../prelude/array';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@ -103,23 +104,23 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
|
||||
if (psErr) throw psErr;
|
||||
|
||||
if (ps.includeUserUsernames != null) {
|
||||
const ids = (await Promise.all(ps.includeUserUsernames.map(async (username) => {
|
||||
const ids = erase(null, await Promise.all(ps.includeUserUsernames.map(async (username) => {
|
||||
const _user = await User.findOne({
|
||||
usernameLower: username.toLowerCase()
|
||||
});
|
||||
return _user ? _user._id : null;
|
||||
}))).filter(id => id != null);
|
||||
})));
|
||||
|
||||
ids.forEach(id => ps.includeUserIds.push(id));
|
||||
}
|
||||
|
||||
if (ps.excludeUserUsernames != null) {
|
||||
const ids = (await Promise.all(ps.excludeUserUsernames.map(async (username) => {
|
||||
const ids = erase(null, await Promise.all(ps.excludeUserUsernames.map(async (username) => {
|
||||
const _user = await User.findOne({
|
||||
usernameLower: username.toLowerCase()
|
||||
});
|
||||
return _user ? _user._id : null;
|
||||
}))).filter(id => id != null);
|
||||
})));
|
||||
|
||||
ids.forEach(id => ps.excludeUserIds.push(id));
|
||||
}
|
||||
|
Reference in New Issue
Block a user