ミス廃: ランキングへの参加をオプトインに
This commit is contained in:
parent
29a68897e1
commit
aaf48cf329
8 changed files with 40 additions and 4 deletions
13
migration/1651804009671-useRanking.ts
Normal file
13
migration/1651804009671-useRanking.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import {MigrationInterface, QueryRunner} from "typeorm";
|
||||||
|
|
||||||
|
export class useRanking1651804009671 implements MigrationInterface {
|
||||||
|
name = 'useRanking1651804009671'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "user" ADD "useRanking" boolean NOT NULL DEFAULT false`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "useRanking"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,4 +19,7 @@ export class UserSetting {
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
template?: string;
|
template?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
useRanking?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ export class SessionController {
|
||||||
if (setting.localOnly != null) s.localOnly = setting.localOnly;
|
if (setting.localOnly != null) s.localOnly = setting.localOnly;
|
||||||
if (setting.remoteFollowersOnly != null) s.remoteFollowersOnly = setting.remoteFollowersOnly;
|
if (setting.remoteFollowersOnly != null) s.remoteFollowersOnly = setting.remoteFollowersOnly;
|
||||||
if (setting.template !== undefined) s.template = setting.template;
|
if (setting.template !== undefined) s.template = setting.template;
|
||||||
|
if (setting.useRanking !== undefined) s.useRanking = setting.useRanking;
|
||||||
if (Object.keys(s).length === 0) return;
|
if (Object.keys(s).length === 0) return;
|
||||||
await updateUser(user.username, user.host, s);
|
await updateUser(user.username, user.host, s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,9 @@ import { User } from '../models/entities/user';
|
||||||
*/
|
*/
|
||||||
export const getRanking = async (limit?: number | null): Promise<User[]> => {
|
export const getRanking = async (limit?: number | null): Promise<User[]> => {
|
||||||
const query = Users.createQueryBuilder('user')
|
const query = Users.createQueryBuilder('user')
|
||||||
.where('"user"."bannedFromRanking" IS NOT TRUE')
|
.where('"user"."useRanking" IS TRUE')
|
||||||
|
.andWhere('"user"."bannedFromRanking" IS NOT TRUE')
|
||||||
|
.andWhere('"user"."rating" <> \'NaN\'')
|
||||||
.orderBy('"user".rating', 'DESC');
|
.orderBy('"user".rating', 'DESC');
|
||||||
|
|
||||||
if (limit) {
|
if (limit) {
|
||||||
|
|
|
@ -93,6 +93,12 @@ export class User implements IUser {
|
||||||
})
|
})
|
||||||
public rating: number;
|
public rating: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
public useRanking: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
|
|
|
@ -20,5 +20,6 @@ export interface IUser {
|
||||||
bannedFromRanking: boolean;
|
bannedFromRanking: boolean;
|
||||||
isAdmin?: boolean;
|
isAdmin?: boolean;
|
||||||
tokenVersion: number;
|
tokenVersion: number;
|
||||||
|
useRanking: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ type SettingDraftType = Partial<Pick<IUser,
|
||||||
| 'localOnly'
|
| 'localOnly'
|
||||||
| 'remoteFollowersOnly'
|
| 'remoteFollowersOnly'
|
||||||
| 'template'
|
| 'template'
|
||||||
|
| 'useRanking'
|
||||||
>>;
|
>>;
|
||||||
|
|
||||||
type DraftReducer = React.Reducer<SettingDraftType, Partial<SettingDraftType>>;
|
type DraftReducer = React.Reducer<SettingDraftType, Partial<SettingDraftType>>;
|
||||||
|
@ -57,6 +58,7 @@ export const MisshaiPage: React.VFC = () => {
|
||||||
localOnly: data?.localOnly ?? false,
|
localOnly: data?.localOnly ?? false,
|
||||||
remoteFollowersOnly: data?.remoteFollowersOnly ?? false,
|
remoteFollowersOnly: data?.remoteFollowersOnly ?? false,
|
||||||
template: data?.template ?? null,
|
template: data?.template ?? null,
|
||||||
|
useRanking: data?.useRanking ?? false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const templateTextarea = useRef<HTMLTextAreaElement>(null);
|
const templateTextarea = useRef<HTMLTextAreaElement>(null);
|
||||||
|
@ -98,6 +100,7 @@ export const MisshaiPage: React.VFC = () => {
|
||||||
localOnly: data.localOnly,
|
localOnly: data.localOnly,
|
||||||
remoteFollowersOnly: data.remoteFollowersOnly,
|
remoteFollowersOnly: data.remoteFollowersOnly,
|
||||||
template: data.template,
|
template: data.template,
|
||||||
|
useRanking: data.useRanking
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
@ -245,7 +248,13 @@ export const MisshaiPage: React.VFC = () => {
|
||||||
<div className="body">
|
<div className="body">
|
||||||
<h1><i className="bi-bar-chart"></i> {t('_missHai.ranking')}</h1>
|
<h1><i className="bi-bar-chart"></i> {t('_missHai.ranking')}</h1>
|
||||||
<Ranking limit={limit} />
|
<Ranking limit={limit} />
|
||||||
{limit && <button className="btn link" onClick={() => setLimit(undefined)}>{t('_missHai.showAll')}</button>}
|
{limit && <button className="btn primary" onClick={() => setLimit(undefined)}>{t('_missHai.showAll')}</button>}
|
||||||
|
<label className="input-check mt-2">
|
||||||
|
<input type="checkbox" checked={draft.useRanking} onChange={(e) => {
|
||||||
|
updateSetting({ useRanking: e.target.checked });
|
||||||
|
}}/>
|
||||||
|
<span>{t('_missHai.useRanking')}</span>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="misshaiPageLayout">
|
<div className="misshaiPageLayout">
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
"error": "エラー",
|
"error": "エラー",
|
||||||
"retry": "やり直す",
|
"retry": "やり直す",
|
||||||
"saved": "保存しました。",
|
"saved": "保存しました。",
|
||||||
"disclaimerForMisskeyHq": "Misskey Toolsは、Misskey HQの公式ツールでは<b>ありません</b>。",
|
"disclaimerForMisskeyHq": "Misskey Toolsは、Misskey Development Divisionの公式ツールでは<b>ありません</b>。",
|
||||||
"translatedByTheCommunity": "Misskey Toolsはボランティアによって翻訳されています。",
|
"translatedByTheCommunity": "Misskey Toolsはボランティアによって翻訳されています。",
|
||||||
"helpTranslation": "翻訳に協力する",
|
"helpTranslation": "翻訳に協力する",
|
||||||
"announcements": "お知らせ",
|
"announcements": "お知らせ",
|
||||||
|
@ -81,7 +81,8 @@
|
||||||
"dataDelta": "前日比",
|
"dataDelta": "前日比",
|
||||||
"rating": "レート",
|
"rating": "レート",
|
||||||
"order": "順位",
|
"order": "順位",
|
||||||
"showRanking": "ランキングを見る"
|
"showRanking": "ランキングを見る",
|
||||||
|
"useRanking": "ランキングに参加する"
|
||||||
},
|
},
|
||||||
"_accounts": {
|
"_accounts": {
|
||||||
"currentAccount": "現在ログインしているアカウント",
|
"currentAccount": "現在ログインしているアカウント",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue