ミス廃: ランキングへの参加をオプトインに
This commit is contained in:
parent
29a68897e1
commit
aaf48cf329
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()
|
||||
template?: string;
|
||||
|
||||
@IsOptional()
|
||||
useRanking?: boolean;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ export class SessionController {
|
||||
if (setting.localOnly != null) s.localOnly = setting.localOnly;
|
||||
if (setting.remoteFollowersOnly != null) s.remoteFollowersOnly = setting.remoteFollowersOnly;
|
||||
if (setting.template !== undefined) s.template = setting.template;
|
||||
if (setting.useRanking !== undefined) s.useRanking = setting.useRanking;
|
||||
if (Object.keys(s).length === 0) return;
|
||||
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[]> => {
|
||||
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');
|
||||
|
||||
if (limit) {
|
||||
|
@ -93,6 +93,12 @@ export class User implements IUser {
|
||||
})
|
||||
public rating: number;
|
||||
|
||||
@Column({
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
})
|
||||
public useRanking: boolean;
|
||||
|
||||
@Column({
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
|
@ -20,5 +20,6 @@ export interface IUser {
|
||||
bannedFromRanking: boolean;
|
||||
isAdmin?: boolean;
|
||||
tokenVersion: number;
|
||||
useRanking: boolean;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ type SettingDraftType = Partial<Pick<IUser,
|
||||
| 'localOnly'
|
||||
| 'remoteFollowersOnly'
|
||||
| 'template'
|
||||
| 'useRanking'
|
||||
>>;
|
||||
|
||||
type DraftReducer = React.Reducer<SettingDraftType, Partial<SettingDraftType>>;
|
||||
@ -57,6 +58,7 @@ export const MisshaiPage: React.VFC = () => {
|
||||
localOnly: data?.localOnly ?? false,
|
||||
remoteFollowersOnly: data?.remoteFollowersOnly ?? false,
|
||||
template: data?.template ?? null,
|
||||
useRanking: data?.useRanking ?? false,
|
||||
});
|
||||
|
||||
const templateTextarea = useRef<HTMLTextAreaElement>(null);
|
||||
@ -98,6 +100,7 @@ export const MisshaiPage: React.VFC = () => {
|
||||
localOnly: data.localOnly,
|
||||
remoteFollowersOnly: data.remoteFollowersOnly,
|
||||
template: data.template,
|
||||
useRanking: data.useRanking
|
||||
});
|
||||
}
|
||||
}, [data]);
|
||||
@ -245,7 +248,13 @@ export const MisshaiPage: React.VFC = () => {
|
||||
<div className="body">
|
||||
<h1><i className="bi-bar-chart"></i> {t('_missHai.ranking')}</h1>
|
||||
<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 className="misshaiPageLayout">
|
||||
|
@ -38,7 +38,7 @@
|
||||
"error": "エラー",
|
||||
"retry": "やり直す",
|
||||
"saved": "保存しました。",
|
||||
"disclaimerForMisskeyHq": "Misskey Toolsは、Misskey HQの公式ツールでは<b>ありません</b>。",
|
||||
"disclaimerForMisskeyHq": "Misskey Toolsは、Misskey Development Divisionの公式ツールでは<b>ありません</b>。",
|
||||
"translatedByTheCommunity": "Misskey Toolsはボランティアによって翻訳されています。",
|
||||
"helpTranslation": "翻訳に協力する",
|
||||
"announcements": "お知らせ",
|
||||
@ -81,7 +81,8 @@
|
||||
"dataDelta": "前日比",
|
||||
"rating": "レート",
|
||||
"order": "順位",
|
||||
"showRanking": "ランキングを見る"
|
||||
"showRanking": "ランキングを見る",
|
||||
"useRanking": "ランキングに参加する"
|
||||
},
|
||||
"_accounts": {
|
||||
"currentAccount": "現在ログインしているアカウント",
|
||||
|
Loading…
Reference in New Issue
Block a user