mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-26 19:10:18 +01:00
enhance: stats apiの重い処理をスキップできるように
This commit is contained in:
parent
ae1d0b08eb
commit
c0efad6ee3
9 changed files with 59 additions and 2 deletions
4
locales/index.d.ts
vendored
4
locales/index.d.ts
vendored
|
@ -5222,6 +5222,10 @@ export interface Locale extends ILocale {
|
||||||
* 注意事項を理解した上でオンにします。
|
* 注意事項を理解した上でオンにします。
|
||||||
*/
|
*/
|
||||||
"acknowledgeNotesAndEnable": string;
|
"acknowledgeNotesAndEnable": string;
|
||||||
|
/**
|
||||||
|
* 拡張されたサーバー統計APIを利用する
|
||||||
|
*/
|
||||||
|
"enableEnhancedServerStats": string;
|
||||||
"_accountSettings": {
|
"_accountSettings": {
|
||||||
/**
|
/**
|
||||||
* コンテンツの表示にログインを必須にする
|
* コンテンツの表示にログインを必須にする
|
||||||
|
|
|
@ -1301,6 +1301,7 @@ lockdown: "ロックダウン"
|
||||||
pleaseSelectAccount: "アカウントを選択してください"
|
pleaseSelectAccount: "アカウントを選択してください"
|
||||||
availableRoles: "利用可能なロール"
|
availableRoles: "利用可能なロール"
|
||||||
acknowledgeNotesAndEnable: "注意事項を理解した上でオンにします。"
|
acknowledgeNotesAndEnable: "注意事項を理解した上でオンにします。"
|
||||||
|
enableEnhancedServerStats: "拡張されたサーバー統計APIを利用する"
|
||||||
|
|
||||||
_accountSettings:
|
_accountSettings:
|
||||||
requireSigninToViewContents: "コンテンツの表示にログインを必須にする"
|
requireSigninToViewContents: "コンテンツの表示にログインを必須にする"
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class EnableEnhancedServerStats1732635823870 {
|
||||||
|
name = 'EnableEnhancedServerStats1732635823870'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "enableEnhancedServerStats" boolean NOT NULL DEFAULT true`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableEnhancedServerStats"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -544,6 +544,11 @@ export class MiMeta {
|
||||||
})
|
})
|
||||||
public enableIdenticonGeneration: boolean;
|
public enableIdenticonGeneration: boolean;
|
||||||
|
|
||||||
|
@Column('boolean', {
|
||||||
|
default: true,
|
||||||
|
})
|
||||||
|
public enableEnhancedServerStats: boolean;
|
||||||
|
|
||||||
@Column('jsonb', {
|
@Column('jsonb', {
|
||||||
default: { },
|
default: { },
|
||||||
})
|
})
|
||||||
|
|
|
@ -356,6 +356,10 @@ export const meta = {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
},
|
},
|
||||||
|
enableEnhancedServerStats: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
enableIdenticonGeneration: {
|
enableIdenticonGeneration: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -641,6 +645,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
enableChartsForFederatedInstances: instance.enableChartsForFederatedInstances,
|
enableChartsForFederatedInstances: instance.enableChartsForFederatedInstances,
|
||||||
enableStatsForFederatedInstances: instance.enableStatsForFederatedInstances,
|
enableStatsForFederatedInstances: instance.enableStatsForFederatedInstances,
|
||||||
enableServerMachineStats: instance.enableServerMachineStats,
|
enableServerMachineStats: instance.enableServerMachineStats,
|
||||||
|
enableEnhancedServerStats: instance.enableEnhancedServerStats,
|
||||||
enableIdenticonGeneration: instance.enableIdenticonGeneration,
|
enableIdenticonGeneration: instance.enableIdenticonGeneration,
|
||||||
bannedEmailDomains: instance.bannedEmailDomains,
|
bannedEmailDomains: instance.bannedEmailDomains,
|
||||||
policies: { ...DEFAULT_POLICIES, ...instance.policies },
|
policies: { ...DEFAULT_POLICIES, ...instance.policies },
|
||||||
|
|
|
@ -138,6 +138,7 @@ export const paramDef = {
|
||||||
enableChartsForFederatedInstances: { type: 'boolean' },
|
enableChartsForFederatedInstances: { type: 'boolean' },
|
||||||
enableStatsForFederatedInstances: { type: 'boolean' },
|
enableStatsForFederatedInstances: { type: 'boolean' },
|
||||||
enableServerMachineStats: { type: 'boolean' },
|
enableServerMachineStats: { type: 'boolean' },
|
||||||
|
enableEnhancedServerStats: { type: 'boolean' },
|
||||||
enableIdenticonGeneration: { type: 'boolean' },
|
enableIdenticonGeneration: { type: 'boolean' },
|
||||||
serverRules: { type: 'array', items: { type: 'string' } },
|
serverRules: { type: 'array', items: { type: 'string' } },
|
||||||
bannedEmailDomains: { type: 'array', items: { type: 'string' } },
|
bannedEmailDomains: { type: 'array', items: { type: 'string' } },
|
||||||
|
@ -587,6 +588,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
set.enableServerMachineStats = ps.enableServerMachineStats;
|
set.enableServerMachineStats = ps.enableServerMachineStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps.enableEnhancedServerStats !== undefined) {
|
||||||
|
set.enableEnhancedServerStats = ps.enableEnhancedServerStats;
|
||||||
|
}
|
||||||
|
|
||||||
if (ps.enableIdenticonGeneration !== undefined) {
|
if (ps.enableIdenticonGeneration !== undefined) {
|
||||||
set.enableIdenticonGeneration = ps.enableIdenticonGeneration;
|
set.enableIdenticonGeneration = ps.enableIdenticonGeneration;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import type { InstancesRepository, NoteReactionsRepository } from '@/models/_.js';
|
import type { MiMeta, InstancesRepository, NoteReactionsRepository } from '@/models/_.js';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import NotesChart from '@/core/chart/charts/notes.js';
|
import NotesChart from '@/core/chart/charts/notes.js';
|
||||||
|
@ -60,6 +60,9 @@ export const paramDef = {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private instanceMeta: MiMeta,
|
||||||
|
|
||||||
@Inject(DI.instancesRepository)
|
@Inject(DI.instancesRepository)
|
||||||
private instancesRepository: InstancesRepository,
|
private instancesRepository: InstancesRepository,
|
||||||
|
|
||||||
|
@ -83,7 +86,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
//originalReactionsCount,
|
//originalReactionsCount,
|
||||||
instances,
|
instances,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
this.noteReactionsRepository.count({ cache: 3600000 }), // 1 hour
|
this.instanceMeta.enableEnhancedServerStats ? this.noteReactionsRepository.count({ cache: 3600000 }) : Promise.resolve(0), // 1 hour
|
||||||
//this.noteReactionsRepository.count({ where: { userHost: IsNull() }, cache: 3600000 }),
|
//this.noteReactionsRepository.count({ where: { userHost: IsNull() }, cache: 3600000 }),
|
||||||
this.instancesRepository.count({ cache: 3600000 }),
|
this.instancesRepository.count({ cache: 3600000 }),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -15,6 +15,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</MkSwitch>
|
</MkSwitch>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="_panel" style="padding: 16px;">
|
||||||
|
<MkSwitch v-model="enableEnhancedServerStats" @change="onChange_enableEnhancedServerStats">
|
||||||
|
<template #label>{{ i18n.ts.enableEnhancedServerStats }}</template>
|
||||||
|
<template #caption>{{ i18n.ts.turnOffToImprovePerformance }}</template>
|
||||||
|
</MkSwitch>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="_panel" style="padding: 16px;">
|
<div class="_panel" style="padding: 16px;">
|
||||||
<MkSwitch v-model="enableIdenticonGeneration" @change="onChange_enableIdenticonGeneration">
|
<MkSwitch v-model="enableIdenticonGeneration" @change="onChange_enableIdenticonGeneration">
|
||||||
<template #label>{{ i18n.ts.enableIdenticonGeneration }}</template>
|
<template #label>{{ i18n.ts.enableIdenticonGeneration }}</template>
|
||||||
|
@ -125,6 +132,7 @@ import MkFormFooter from '@/components/MkFormFooter.vue';
|
||||||
const meta = await misskeyApi('admin/meta');
|
const meta = await misskeyApi('admin/meta');
|
||||||
|
|
||||||
const enableServerMachineStats = ref(meta.enableServerMachineStats);
|
const enableServerMachineStats = ref(meta.enableServerMachineStats);
|
||||||
|
const enableEnhancedServerStats = ref(meta.enableEnhancedServerStats);
|
||||||
const enableIdenticonGeneration = ref(meta.enableIdenticonGeneration);
|
const enableIdenticonGeneration = ref(meta.enableIdenticonGeneration);
|
||||||
const enableChartsForRemoteUser = ref(meta.enableChartsForRemoteUser);
|
const enableChartsForRemoteUser = ref(meta.enableChartsForRemoteUser);
|
||||||
const enableStatsForFederatedInstances = ref(meta.enableStatsForFederatedInstances);
|
const enableStatsForFederatedInstances = ref(meta.enableStatsForFederatedInstances);
|
||||||
|
@ -138,6 +146,14 @@ function onChange_enableServerMachineStats(value: boolean) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onChange_enableEnhancedServerStats(value: boolean) {
|
||||||
|
os.apiWithDialog('admin/update-meta', {
|
||||||
|
enableEnhancedServerStats: value,
|
||||||
|
}).then(() => {
|
||||||
|
fetchInstance(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function onChange_enableIdenticonGeneration(value: boolean) {
|
function onChange_enableIdenticonGeneration(value: boolean) {
|
||||||
os.apiWithDialog('admin/update-meta', {
|
os.apiWithDialog('admin/update-meta', {
|
||||||
enableIdenticonGeneration: value,
|
enableIdenticonGeneration: value,
|
||||||
|
|
|
@ -5179,6 +5179,7 @@ export type operations = {
|
||||||
enableChartsForFederatedInstances: boolean;
|
enableChartsForFederatedInstances: boolean;
|
||||||
enableStatsForFederatedInstances: boolean;
|
enableStatsForFederatedInstances: boolean;
|
||||||
enableServerMachineStats: boolean;
|
enableServerMachineStats: boolean;
|
||||||
|
enableEnhancedServerStats: boolean;
|
||||||
enableIdenticonGeneration: boolean;
|
enableIdenticonGeneration: boolean;
|
||||||
manifestJsonOverride: string;
|
manifestJsonOverride: string;
|
||||||
policies: Record<string, never>;
|
policies: Record<string, never>;
|
||||||
|
@ -9575,6 +9576,7 @@ export type operations = {
|
||||||
enableChartsForFederatedInstances?: boolean;
|
enableChartsForFederatedInstances?: boolean;
|
||||||
enableStatsForFederatedInstances?: boolean;
|
enableStatsForFederatedInstances?: boolean;
|
||||||
enableServerMachineStats?: boolean;
|
enableServerMachineStats?: boolean;
|
||||||
|
enableEnhancedServerStats?: boolean;
|
||||||
enableIdenticonGeneration?: boolean;
|
enableIdenticonGeneration?: boolean;
|
||||||
serverRules?: string[];
|
serverRules?: string[];
|
||||||
bannedEmailDomains?: string[];
|
bannedEmailDomains?: string[];
|
||||||
|
|
Loading…
Reference in a new issue