feat: notes/instance/perUserNotesチャートに添付ファイル付きノートの数を追加
This commit is contained in:
27
packages/backend/migration/1644328606241-chart-v12.js
Normal file
27
packages/backend/migration/1644328606241-chart-v12.js
Normal file
@ -0,0 +1,27 @@
|
||||
const { MigrationInterface, QueryRunner } = require("typeorm");
|
||||
|
||||
module.exports = class chartV121644328606241 {
|
||||
name = 'chartV121644328606241'
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "__chart__notes" ADD "___local_diffs_withFile" integer NOT NULL DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart__notes" ADD "___remote_diffs_withFile" integer NOT NULL DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart_day__notes" ADD "___local_diffs_withFile" integer NOT NULL DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart_day__notes" ADD "___remote_diffs_withFile" integer NOT NULL DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart__instance" ADD "___notes_diffs_withFile" integer NOT NULL DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart_day__instance" ADD "___notes_diffs_withFile" integer NOT NULL DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart__per_user_notes" ADD "___diffs_withFile" smallint NOT NULL DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart_day__per_user_notes" ADD "___diffs_withFile" smallint NOT NULL DEFAULT '0'`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "__chart_day__per_user_notes" DROP COLUMN "___diffs_withFile"`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart__per_user_notes" DROP COLUMN "___diffs_withFile"`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart_day__instance" DROP COLUMN "___notes_diffs_withFile"`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart__instance" DROP COLUMN "___notes_diffs_withFile"`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart_day__notes" DROP COLUMN "___remote_diffs_withFile"`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart_day__notes" DROP COLUMN "___local_diffs_withFile"`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart__notes" DROP COLUMN "___remote_diffs_withFile"`);
|
||||
await queryRunner.query(`ALTER TABLE "__chart__notes" DROP COLUMN "___local_diffs_withFile"`);
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ export const schema = {
|
||||
'notes.diffs.normal': {},
|
||||
'notes.diffs.reply': {},
|
||||
'notes.diffs.renote': {},
|
||||
'notes.diffs.withFile': {},
|
||||
'users.total': { accumulate: true },
|
||||
'users.inc': { range: 'small' },
|
||||
'users.dec': { range: 'small' },
|
||||
|
@ -9,12 +9,14 @@ export const schema = {
|
||||
'local.diffs.normal': {},
|
||||
'local.diffs.reply': {},
|
||||
'local.diffs.renote': {},
|
||||
'local.diffs.withFile': {},
|
||||
'remote.total': { accumulate: true },
|
||||
'remote.inc': {},
|
||||
'remote.dec': {},
|
||||
'remote.diffs.normal': {},
|
||||
'remote.diffs.reply': {},
|
||||
'remote.diffs.renote': {},
|
||||
'remote.diffs.withFile': {},
|
||||
} as const;
|
||||
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
||||
|
@ -9,6 +9,7 @@ export const schema = {
|
||||
'diffs.normal': { range: 'small' },
|
||||
'diffs.reply': { range: 'small' },
|
||||
'diffs.renote': { range: 'small' },
|
||||
'diffs.withFile': { range: 'small' },
|
||||
} as const;
|
||||
|
||||
export const entity = Chart.schemaToEntity(name, schema, true);
|
||||
|
@ -74,6 +74,7 @@ export default class InstanceChart extends Chart<typeof schema> {
|
||||
'notes.diffs.normal': note.replyId == null && note.renoteId == null ? (isAdditional ? 1 : -1) : 0,
|
||||
'notes.diffs.renote': note.renoteId != null ? (isAdditional ? 1 : -1) : 0,
|
||||
'notes.diffs.reply': note.replyId != null ? (isAdditional ? 1 : -1) : 0,
|
||||
'notes.diffs.withFile': note.fileIds.length > 0 ? (isAdditional ? 1 : -1) : 0,
|
||||
}, toPuny(host));
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ export default class NotesChart extends Chart<typeof schema> {
|
||||
[`${prefix}.diffs.normal`]: note.replyId == null && note.renoteId == null ? (isAdditional ? 1 : -1) : 0,
|
||||
[`${prefix}.diffs.renote`]: note.renoteId != null ? (isAdditional ? 1 : -1) : 0,
|
||||
[`${prefix}.diffs.reply`]: note.replyId != null ? (isAdditional ? 1 : -1) : 0,
|
||||
[`${prefix}.diffs.withFile`]: note.fileIds.length > 0 ? (isAdditional ? 1 : -1) : 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ export default class PerUserNotesChart extends Chart<typeof schema> {
|
||||
'diffs.normal': note.replyId == null && note.renoteId == null ? (isAdditional ? 1 : -1) : 0,
|
||||
'diffs.renote': note.renoteId != null ? (isAdditional ? 1 : -1) : 0,
|
||||
'diffs.reply': note.replyId != null ? (isAdditional ? 1 : -1) : 0,
|
||||
'diffs.withFile': note.fileIds.length > 0 ? (isAdditional ? 1 : -1) : 0,
|
||||
}, user.id);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user