Merge branch 'develop' into sw-notification-action

This commit is contained in:
tamaina
2021-06-29 22:45:12 +09:00
332 changed files with 1385 additions and 3411 deletions

View File

@@ -5,7 +5,6 @@ export const logSchema = {
users: {
type: 'array' as const,
optional: false as const, nullable: false as const,
description: 'アクティブユーザー',
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,

View File

@@ -5,7 +5,6 @@ const logSchema = {
totalCount: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全ドライブファイル数'
},
/**
@@ -14,7 +13,6 @@ const logSchema = {
totalSize: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全ドライブファイルの合計サイズ'
},
/**
@@ -23,7 +21,6 @@ const logSchema = {
incCount: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したドライブファイル数'
},
/**
@@ -32,7 +29,6 @@ const logSchema = {
incSize: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したドライブ使用量'
},
/**
@@ -41,7 +37,6 @@ const logSchema = {
decCount: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したドライブファイル数'
},
/**
@@ -50,7 +45,6 @@ const logSchema = {
decSize: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したドライブ使用量'
},
};

View File

@@ -12,17 +12,14 @@ export const schema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'インスタンス数の合計'
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加インスタンス数'
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少インスタンス数'
},
}
}

View File

@@ -5,7 +5,6 @@ export const logSchema = {
users: {
type: 'array' as const,
optional: false as const, nullable: false as const,
description: '投稿したユーザー',
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,

View File

@@ -12,17 +12,14 @@ export const schema = {
failed: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '失敗したリクエスト数'
},
succeeded: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '成功したリクエスト数'
},
received: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '受信したリクエスト数'
},
}
},
@@ -34,17 +31,14 @@ export const schema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全投稿数'
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加した投稿数'
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少した投稿数'
},
diffs: {
@@ -54,19 +48,16 @@ export const schema = {
normal: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '通常の投稿数の差分'
},
reply: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'リプライの投稿数の差分'
},
renote: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'Renoteの投稿数の差分'
},
}
},
@@ -80,17 +71,14 @@ export const schema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全ユーザー数'
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したユーザー数'
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したユーザー数'
},
}
},
@@ -102,17 +90,14 @@ export const schema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全フォロー数'
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したフォロー数'
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したフォロー数'
},
}
},
@@ -124,17 +109,14 @@ export const schema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全フォロワー数'
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したフォロワー数'
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したフォロワー数'
},
}
},
@@ -146,32 +128,26 @@ export const schema = {
totalFiles: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全ドライブファイル数'
},
totalUsage: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全ドライブファイルの合計サイズ'
},
incFiles: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したドライブファイル数'
},
incUsage: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したドライブ使用量'
},
decFiles: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したドライブファイル数'
},
decUsage: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したドライブ使用量'
},
}
},

View File

@@ -8,27 +8,22 @@ export const schema = {
incomingRequests: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '受信したリクエスト数'
},
outgoingRequests: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '送信したリクエスト数'
},
totalTime: {
totalTime: { // TIP: (totalTime / incomingRequests) でひとつのリクエストに平均でどれくらいの時間がかかったか知れる
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '応答時間の合計' // TIP: (totalTime / incomingRequests) でひとつのリクエストに平均でどれくらいの時間がかかったか知れる
},
incomingBytes: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '合計受信データ量'
},
outgoingBytes: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '合計送信データ量'
},
}
};

View File

@@ -2,19 +2,16 @@ const logSchema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全投稿数'
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加した投稿数'
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少した投稿数'
},
diffs: {
@@ -24,19 +21,16 @@ const logSchema = {
normal: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '通常の投稿数の差分'
},
reply: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'リプライの投稿数の差分'
},
renote: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'Renoteの投稿数の差分'
},
}
},

View File

@@ -8,7 +8,6 @@ export const schema = {
totalCount: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全ドライブファイル数'
},
/**
@@ -17,7 +16,6 @@ export const schema = {
totalSize: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全ドライブファイルの合計サイズ'
},
/**
@@ -26,7 +24,6 @@ export const schema = {
incCount: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したドライブファイル数'
},
/**
@@ -35,7 +32,6 @@ export const schema = {
incSize: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したドライブ使用量'
},
/**
@@ -44,7 +40,6 @@ export const schema = {
decCount: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したドライブファイル数'
},
/**
@@ -53,7 +48,6 @@ export const schema = {
decSize: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したドライブ使用量'
},
}
};

View File

@@ -12,7 +12,6 @@ export const logSchema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'フォローしている合計',
},
/**
@@ -21,7 +20,6 @@ export const logSchema = {
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'フォローした数',
},
/**
@@ -30,7 +28,6 @@ export const logSchema = {
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'フォロー解除した数',
},
}
},
@@ -48,7 +45,6 @@ export const logSchema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'フォローされている合計',
},
/**
@@ -57,7 +53,6 @@ export const logSchema = {
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'フォローされた数',
},
/**
@@ -66,7 +61,6 @@ export const logSchema = {
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'フォロー解除された数',
},
}
},

View File

@@ -5,19 +5,16 @@ export const schema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全投稿数'
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加した投稿数'
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少した投稿数'
},
diffs: {
@@ -27,19 +24,16 @@ export const schema = {
normal: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '通常の投稿数の差分'
},
reply: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'リプライの投稿数の差分'
},
renote: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'Renoteの投稿数の差分'
},
}
},

View File

@@ -5,7 +5,6 @@ export const logSchema = {
count: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: 'リアクションされた数',
},
};

View File

@@ -9,19 +9,16 @@ export const schema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: ''
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: ''
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: ''
},
}
}

View File

@@ -9,19 +9,16 @@ export const schema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: ''
},
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: ''
},
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: ''
},
}
}

View File

@@ -5,7 +5,6 @@ const logSchema = {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '集計期間時点での、全ユーザー数'
},
/**
@@ -14,7 +13,6 @@ const logSchema = {
inc: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '増加したユーザー数'
},
/**
@@ -23,7 +21,6 @@ const logSchema = {
dec: {
type: 'number' as const,
optional: false as const, nullable: false as const,
description: '減少したユーザー数'
},
};

View File

@@ -93,7 +93,7 @@ export default abstract class Chart<T extends Record<string, any>> {
}
@autobind
private static convertFlattenColumnsToObject(x: Record<string, number>) {
private static convertFlattenColumnsToObject(x: Record<string, any>): Record<string, any> {
const obj = {} as any;
for (const k of Object.keys(x).filter(k => k.startsWith(Chart.columnPrefix))) {
// now k is ___x_y_z
@@ -285,8 +285,7 @@ export default abstract class Chart<T extends Record<string, any>> {
const latest = await this.getLatestLog(group);
if (latest != null) {
const obj = Chart.convertFlattenColumnsToObject(
latest as Record<string, any>);
const obj = Chart.convertFlattenColumnsToObject(latest) as T;
// 空ログデータを作成
data = this.getNewLog(obj);
@@ -474,13 +473,13 @@ export default abstract class Chart<T extends Record<string, any>> {
const log = logs.find(l => isTimeSame(new Date(l.date * 1000), current));
if (log) {
const data = Chart.convertFlattenColumnsToObject(log as Record<string, any>);
chart.unshift(Chart.countUniqueFields(data));
const data = Chart.convertFlattenColumnsToObject(log);
chart.unshift(Chart.countUniqueFields(data) as T);
} else {
// 隙間埋め
const latest = logs.find(l => isTimeBefore(new Date(l.date * 1000), current));
const data = latest ? Chart.convertFlattenColumnsToObject(latest as Record<string, any>) : null;
chart.unshift(Chart.countUniqueFields(this.getNewLog(data)));
const data = latest ? Chart.convertFlattenColumnsToObject(latest) as T : null;
chart.unshift(Chart.countUniqueFields(this.getNewLog(data)) as T);
}
}
} else if (span === 'day') {
@@ -497,14 +496,14 @@ export default abstract class Chart<T extends Record<string, any>> {
if (log) {
if (logsForEachDays[currentDayIndex]) {
logsForEachDays[currentDayIndex].unshift(Chart.convertFlattenColumnsToObject(log));
logsForEachDays[currentDayIndex].unshift(Chart.convertFlattenColumnsToObject(log) as T);
} else {
logsForEachDays[currentDayIndex] = [Chart.convertFlattenColumnsToObject(log)];
logsForEachDays[currentDayIndex] = [Chart.convertFlattenColumnsToObject(log) as T];
}
} else {
// 隙間埋め
const latest = logs.find(l => isTimeBefore(new Date(l.date * 1000), current));
const data = latest ? Chart.convertFlattenColumnsToObject(latest as Record<string, any>) : null;
const data = latest ? Chart.convertFlattenColumnsToObject(latest) as T : null;
const newLog = this.getNewLog(data);
if (logsForEachDays[currentDayIndex]) {
logsForEachDays[currentDayIndex].unshift(newLog);
@@ -516,7 +515,7 @@ export default abstract class Chart<T extends Record<string, any>> {
for (const logs of logsForEachDays) {
const log = this.aggregate(logs);
chart.unshift(Chart.countUniqueFields(log));
chart.unshift(Chart.countUniqueFields(log) as T);
}
}

View File

@@ -267,7 +267,8 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string,
async function deleteOldFile(user: IRemoteUser) {
const q = DriveFiles.createQueryBuilder('file')
.where('file.userId = :userId', { userId: user.id });
.where('file.userId = :userId', { userId: user.id })
.andWhere('file.isLink = FALSE');
if (user.avatarId) {
q.andWhere('file.id != :avatarId', { avatarId: user.avatarId });

View File

@@ -79,7 +79,7 @@ async function postProcess(file: DriveFile, isExpired = false) {
url: file.uri,
thumbnailUrl: null,
webpublicUrl: null,
size: 0,
storedInternal: false,
// ローカルプロキシ用
accessKey: uuid(),
thumbnailAccessKey: 'thumbnail-' + uuid(),

View File

@@ -25,6 +25,12 @@ export default async (
name = null;
}
// If the comment is same as the name, skip comment
// (image.name is passed in when receiving attachment)
if (comment !== null && name == comment) {
comment = null;
}
// Create temp file
const [path, cleanup] = await createTemp();