ミス廃: ランキングへの参加をオプトインに

This commit is contained in:
Ebise Lutica 2022-05-06 11:47:28 +09:00
parent 29a68897e1
commit aaf48cf329
8 changed files with 40 additions and 4 deletions

View 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"`);
}
}

View File

@ -19,4 +19,7 @@ export class UserSetting {
@IsOptional()
template?: string;
@IsOptional()
useRanking?: boolean;
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -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,

View File

@ -20,5 +20,6 @@ export interface IUser {
bannedFromRanking: boolean;
isAdmin?: boolean;
tokenVersion: number;
useRanking: boolean;
}

View File

@ -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">

View File

@ -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": "現在ログインしているアカウント",