summaryrefslogtreecommitdiff
path: root/packages/backend/src/services/chart/charts/entities
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-12-14 18:12:37 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-12-14 18:12:37 +0900
commit0be4e1046239f1ed62bb73d4df51a7b9eb1a135f (patch)
tree5e0c0d37036490e25073e14e2f9520d257eaa6d4 /packages/backend/src/services/chart/charts/entities
parentNew Crowdin updates (#8033) (diff)
downloadmisskey-0be4e1046239f1ed62bb73d4df51a7b9eb1a135f.tar.gz
misskey-0be4e1046239f1ed62bb73d4df51a7b9eb1a135f.tar.bz2
misskey-0be4e1046239f1ed62bb73d4df51a7b9eb1a135f.zip
enhance(backend): improve chart engine
Diffstat (limited to 'packages/backend/src/services/chart/charts/entities')
-rw-r--r--packages/backend/src/services/chart/charts/entities/active-users.ts36
-rw-r--r--packages/backend/src/services/chart/charts/entities/drive.ts72
-rw-r--r--packages/backend/src/services/chart/charts/entities/federation.ts30
-rw-r--r--packages/backend/src/services/chart/charts/entities/hashtag.ts36
-rw-r--r--packages/backend/src/services/chart/charts/entities/instance.ts158
-rw-r--r--packages/backend/src/services/chart/charts/entities/network.ts32
-rw-r--r--packages/backend/src/services/chart/charts/entities/notes.ts60
-rw-r--r--packages/backend/src/services/chart/charts/entities/per-user-drive.ts59
-rw-r--r--packages/backend/src/services/chart/charts/entities/per-user-following.ts90
-rw-r--r--packages/backend/src/services/chart/charts/entities/per-user-notes.ts47
-rw-r--r--packages/backend/src/services/chart/charts/entities/per-user-reactions.ts32
-rw-r--r--packages/backend/src/services/chart/charts/entities/test-grouped.ts32
-rw-r--r--packages/backend/src/services/chart/charts/entities/test-unique.ts20
-rw-r--r--packages/backend/src/services/chart/charts/entities/test.ts32
-rw-r--r--packages/backend/src/services/chart/charts/entities/users.ts48
15 files changed, 784 insertions, 0 deletions
diff --git a/packages/backend/src/services/chart/charts/entities/active-users.ts b/packages/backend/src/services/chart/charts/entities/active-users.ts
new file mode 100644
index 0000000000..d6b49c86c3
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/active-users.ts
@@ -0,0 +1,36 @@
+import Chart from '../../core';
+
+export const name = 'activeUsers';
+
+const logSchema = {
+ /**
+ * アクティブユーザー
+ */
+ users: {
+ type: 'array' as const,
+ optional: false as const, nullable: false as const,
+ items: {
+ type: 'string' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+};
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ local: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ remote: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema);
diff --git a/packages/backend/src/services/chart/charts/entities/drive.ts b/packages/backend/src/services/chart/charts/entities/drive.ts
new file mode 100644
index 0000000000..3362cbd4cb
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/drive.ts
@@ -0,0 +1,72 @@
+import Chart from '../../core';
+
+export const name = 'drive';
+
+const logSchema = {
+ /**
+ * 集計期間時点での、全ドライブファイル数
+ */
+ totalCount: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 集計期間時点での、全ドライブファイルの合計サイズ
+ */
+ totalSize: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 増加したドライブファイル数
+ */
+ incCount: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 増加したドライブ使用量
+ */
+ incSize: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 減少したドライブファイル数
+ */
+ decCount: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 減少したドライブ使用量
+ */
+ decSize: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+};
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ local: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ remote: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema);
diff --git a/packages/backend/src/services/chart/charts/entities/federation.ts b/packages/backend/src/services/chart/charts/entities/federation.ts
new file mode 100644
index 0000000000..836116bd06
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/federation.ts
@@ -0,0 +1,30 @@
+import Chart from '../../core';
+
+export const name = 'federation';
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ instance: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema);
diff --git a/packages/backend/src/services/chart/charts/entities/hashtag.ts b/packages/backend/src/services/chart/charts/entities/hashtag.ts
new file mode 100644
index 0000000000..43e15456a5
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/hashtag.ts
@@ -0,0 +1,36 @@
+import Chart from '../../core';
+
+export const name = 'hashtag';
+
+const logSchema = {
+ /**
+ * 投稿したユーザー
+ */
+ users: {
+ type: 'array' as const,
+ optional: false as const, nullable: false as const,
+ items: {
+ type: 'string' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+};
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ local: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ remote: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema, true);
diff --git a/packages/backend/src/services/chart/charts/entities/instance.ts b/packages/backend/src/services/chart/charts/entities/instance.ts
new file mode 100644
index 0000000000..9d1f651dbb
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/instance.ts
@@ -0,0 +1,158 @@
+import Chart from '../../core';
+
+export const name = 'instance';
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ requests: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ failed: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ succeeded: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ received: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+
+ notes: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ diffs: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ normal: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ reply: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ renote: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+ },
+ },
+
+ users: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+
+ following: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+
+ followers: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+
+ drive: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ totalFiles: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ totalUsage: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ incFiles: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ incUsage: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ decFiles: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ decUsage: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema, true);
diff --git a/packages/backend/src/services/chart/charts/entities/network.ts b/packages/backend/src/services/chart/charts/entities/network.ts
new file mode 100644
index 0000000000..3d4fffb855
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/network.ts
@@ -0,0 +1,32 @@
+import Chart from '../../core';
+
+export const name = 'network';
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ incomingRequests: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ outgoingRequests: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ totalTime: { // TIP: (totalTime / incomingRequests) でひとつのリクエストに平均でどれくらいの時間がかかったか知れる
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ incomingBytes: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ outgoingBytes: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema);
diff --git a/packages/backend/src/services/chart/charts/entities/notes.ts b/packages/backend/src/services/chart/charts/entities/notes.ts
new file mode 100644
index 0000000000..554d3abe12
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/notes.ts
@@ -0,0 +1,60 @@
+import Chart from '../../core';
+
+export const name = 'notes';
+
+const logSchema = {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ diffs: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ normal: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ reply: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ renote: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+};
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ local: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ remote: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema);
diff --git a/packages/backend/src/services/chart/charts/entities/per-user-drive.ts b/packages/backend/src/services/chart/charts/entities/per-user-drive.ts
new file mode 100644
index 0000000000..ebf64e733e
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/per-user-drive.ts
@@ -0,0 +1,59 @@
+import Chart from '../../core';
+
+export const name = 'perUserDrive';
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ /**
+ * 集計期間時点での、全ドライブファイル数
+ */
+ totalCount: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 集計期間時点での、全ドライブファイルの合計サイズ
+ */
+ totalSize: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 増加したドライブファイル数
+ */
+ incCount: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 増加したドライブ使用量
+ */
+ incSize: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 減少したドライブファイル数
+ */
+ decCount: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 減少したドライブ使用量
+ */
+ decSize: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema, true);
diff --git a/packages/backend/src/services/chart/charts/entities/per-user-following.ts b/packages/backend/src/services/chart/charts/entities/per-user-following.ts
new file mode 100644
index 0000000000..8016c5fe97
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/per-user-following.ts
@@ -0,0 +1,90 @@
+import Chart from '../../core';
+
+export const name = 'perUserFollowing';
+
+const logSchema = {
+ /**
+ * フォローしている
+ */
+ followings: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ /**
+ * フォローしている合計
+ */
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * フォローした数
+ */
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * フォロー解除した数
+ */
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+
+ /**
+ * フォローされている
+ */
+ followers: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ /**
+ * フォローされている合計
+ */
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * フォローされた数
+ */
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * フォロー解除された数
+ */
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+};
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ local: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ remote: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema, true);
diff --git a/packages/backend/src/services/chart/charts/entities/per-user-notes.ts b/packages/backend/src/services/chart/charts/entities/per-user-notes.ts
new file mode 100644
index 0000000000..d8f645b36e
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/per-user-notes.ts
@@ -0,0 +1,47 @@
+import Chart from '../../core';
+
+export const name = 'perUserNotes';
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ diffs: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ normal: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ reply: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ renote: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema, true);
diff --git a/packages/backend/src/services/chart/charts/entities/per-user-reactions.ts b/packages/backend/src/services/chart/charts/entities/per-user-reactions.ts
new file mode 100644
index 0000000000..bcb7012661
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/per-user-reactions.ts
@@ -0,0 +1,32 @@
+import Chart from '../../core';
+
+export const name = 'perUserReaction';
+
+const logSchema = {
+ /**
+ * 被リアクション数
+ */
+ count: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+};
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ local: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ remote: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema, true);
diff --git a/packages/backend/src/services/chart/charts/entities/test-grouped.ts b/packages/backend/src/services/chart/charts/entities/test-grouped.ts
new file mode 100644
index 0000000000..ca1c8c5700
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/test-grouped.ts
@@ -0,0 +1,32 @@
+import Chart from '../../core';
+
+export const name = 'testGrouped';
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ foo: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema, true);
diff --git a/packages/backend/src/services/chart/charts/entities/test-unique.ts b/packages/backend/src/services/chart/charts/entities/test-unique.ts
new file mode 100644
index 0000000000..2e917ee9ed
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/test-unique.ts
@@ -0,0 +1,20 @@
+import Chart from '../../core';
+
+export const name = 'testUnique';
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ foo: {
+ type: 'array' as const,
+ optional: false as const, nullable: false as const,
+ items: {
+ type: 'string' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema);
diff --git a/packages/backend/src/services/chart/charts/entities/test.ts b/packages/backend/src/services/chart/charts/entities/test.ts
new file mode 100644
index 0000000000..fa536ff2cf
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/test.ts
@@ -0,0 +1,32 @@
+import Chart from '../../core';
+
+export const name = 'test';
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ foo: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+ },
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema);
diff --git a/packages/backend/src/services/chart/charts/entities/users.ts b/packages/backend/src/services/chart/charts/entities/users.ts
new file mode 100644
index 0000000000..08d51c9414
--- /dev/null
+++ b/packages/backend/src/services/chart/charts/entities/users.ts
@@ -0,0 +1,48 @@
+import Chart from '../../core';
+
+export const name = 'users';
+
+const logSchema = {
+ /**
+ * 集計期間時点での、全ユーザー数
+ */
+ total: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 増加したユーザー数
+ */
+ inc: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+
+ /**
+ * 減少したユーザー数
+ */
+ dec: {
+ type: 'number' as const,
+ optional: false as const, nullable: false as const,
+ },
+};
+
+export const schema = {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ local: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ remote: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: logSchema,
+ },
+ },
+};
+
+export const entity = Chart.schemaToEntity(name, schema);