iceshrimp/src/server/api/endpoints/admin/vacuum.ts

34 lines
512 B
TypeScript
Raw Normal View History

2019-07-03 03:58:45 +09:00
import $ from 'cafy';
import define from '../../define';
import { getConnection } from 'typeorm';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
params: {
full: {
validator: $.bool,
},
analyze: {
validator: $.bool,
},
}
};
export default define(meta, async (ps) => {
const params: string[] = [];
if (ps.full) {
params.push('FULL');
}
if (ps.analyze) {
params.push('ANALYZE');
}
getConnection().query('VACUUM ' + params.join(' '));
});