@hedhog/admin 0.48.3 → 0.48.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/consts/body.d.ts.map +1 -1
- package/dist/core/core.controller.d.ts +7 -1
- package/dist/core/core.controller.d.ts.map +1 -1
- package/dist/core/core.service.d.ts +9 -1
- package/dist/core/core.service.d.ts.map +1 -1
- package/dist/core/core.service.js +75 -2
- package/dist/core/core.service.js.map +1 -1
- package/dist/emails/lib.d.ts.map +1 -1
- package/dist/menu/menu.controller.d.ts +3 -3
- package/dist/menu/menu.service.d.ts +3 -3
- package/package.json +48 -46
- package/src/core/core.service.ts +79 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/auth/consts/body.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/auth/consts/body.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,QAAS,MAAM,KAAG,MA0BrC,CAAC"}
|
@@ -4,6 +4,7 @@ export declare class CoreController {
|
|
4
4
|
constructor(service: CoreService);
|
5
5
|
index(): Promise<{
|
6
6
|
os: {
|
7
|
+
name: string;
|
7
8
|
platform: NodeJS.Platform;
|
8
9
|
version: string;
|
9
10
|
architecture: string;
|
@@ -25,7 +26,12 @@ export declare class CoreController {
|
|
25
26
|
total: number;
|
26
27
|
admin: number;
|
27
28
|
active: number;
|
28
|
-
activities: any
|
29
|
+
activities: any;
|
30
|
+
};
|
31
|
+
database: {
|
32
|
+
connections: number;
|
33
|
+
size: number;
|
34
|
+
queriesPerSecond: number;
|
29
35
|
};
|
30
36
|
}>;
|
31
37
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"core.controller.d.ts","sourceRoot":"","sources":["../../src/core/core.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBACa,cAAc;IAGvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,WAAW;IAIjC,KAAK
|
1
|
+
{"version":3,"file":"core.controller.d.ts","sourceRoot":"","sources":["../../src/core/core.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBACa,cAAc;IAGvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,WAAW;IAIjC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGZ"}
|
@@ -4,6 +4,7 @@ export declare class CoreService {
|
|
4
4
|
constructor(prismaService: PrismaService);
|
5
5
|
index(): Promise<{
|
6
6
|
os: {
|
7
|
+
name: string;
|
7
8
|
platform: NodeJS.Platform;
|
8
9
|
version: string;
|
9
10
|
architecture: string;
|
@@ -25,9 +26,16 @@ export declare class CoreService {
|
|
25
26
|
total: number;
|
26
27
|
admin: number;
|
27
28
|
active: number;
|
28
|
-
activities: any
|
29
|
+
activities: any;
|
30
|
+
};
|
31
|
+
database: {
|
32
|
+
connections: number;
|
33
|
+
size: number;
|
34
|
+
queriesPerSecond: number;
|
29
35
|
};
|
30
36
|
}>;
|
37
|
+
private getFriendlyOSName;
|
38
|
+
private getDatabaseInfo;
|
31
39
|
private getUsersInfo;
|
32
40
|
private getModulesInfo;
|
33
41
|
private getLatestVersion;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"core.service.d.ts","sourceRoot":"","sources":["../../src/core/core.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,qBACa,WAAW;IACV,OAAO,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAE1C,KAAK
|
1
|
+
{"version":3,"file":"core.service.d.ts","sourceRoot":"","sources":["../../src/core/core.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,qBACa,WAAW;IACV,OAAO,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAE1C,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsBX,OAAO,CAAC,iBAAiB;YAqBX,eAAe;YAgCf,YAAY;YA4CZ,cAAc;YAoCd,gBAAgB;IAkB9B,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,aAAa;YAOP,WAAW;IA2BzB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,iBAAiB;CAkB1B"}
|
@@ -59,6 +59,7 @@ let CoreService = class CoreService {
|
|
59
59
|
const averageSpeed = totalSpeed / cpus.length;
|
60
60
|
return {
|
61
61
|
os: {
|
62
|
+
name: this.getFriendlyOSName(),
|
62
63
|
platform: os.platform(),
|
63
64
|
version: os.release(),
|
64
65
|
architecture: os.arch(),
|
@@ -69,6 +70,57 @@ let CoreService = class CoreService {
|
|
69
70
|
},
|
70
71
|
modules: await this.getModulesInfo(),
|
71
72
|
users: await this.getUsersInfo(),
|
73
|
+
database: await this.getDatabaseInfo(),
|
74
|
+
};
|
75
|
+
}
|
76
|
+
getFriendlyOSName() {
|
77
|
+
switch (os.platform()) {
|
78
|
+
case 'aix':
|
79
|
+
return `AIX`;
|
80
|
+
case 'darwin':
|
81
|
+
return `macOS`;
|
82
|
+
case 'freebsd':
|
83
|
+
return `FreeBSD`;
|
84
|
+
case 'linux':
|
85
|
+
return `Linux`;
|
86
|
+
case 'openbsd':
|
87
|
+
return `OpenBSD`;
|
88
|
+
case 'sunos':
|
89
|
+
return `SunOS`;
|
90
|
+
case 'win32':
|
91
|
+
return `Windows`;
|
92
|
+
default:
|
93
|
+
return `Unknown`;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
async getDatabaseInfo() {
|
97
|
+
let connections, size, queriesPerSecond;
|
98
|
+
if (process.env.DATABASE_URL.includes('postgres')) {
|
99
|
+
[connections, size, queriesPerSecond] = await Promise.all([
|
100
|
+
this.prismaService.$queryRaw `SELECT COUNT(*) FROM pg_stat_activity`, // For PostgreSQL
|
101
|
+
this.prismaService
|
102
|
+
.$queryRaw `SELECT pg_database_size(current_database())`, // For PostgreSQL
|
103
|
+
this.prismaService
|
104
|
+
.$queryRaw `SELECT sum(numbackends) FROM pg_stat_database`, // For PostgreSQL
|
105
|
+
]);
|
106
|
+
}
|
107
|
+
else if (process.env.DATABASE_URL.includes('mysql')) {
|
108
|
+
[connections, size, queriesPerSecond] = await Promise.all([
|
109
|
+
this.prismaService
|
110
|
+
.$queryRaw `SHOW STATUS WHERE variable_name = 'Threads_connected'`, // For MySQL
|
111
|
+
this.prismaService
|
112
|
+
.$queryRaw `SELECT SUM(data_length + index_length) AS size FROM information_schema.tables WHERE table_schema = DATABASE()`, // For MySQL
|
113
|
+
this.prismaService
|
114
|
+
.$queryRaw `SHOW STATUS WHERE variable_name = 'Queries'`, // For MySQL
|
115
|
+
]);
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
throw new Error('Unsupported database type');
|
119
|
+
}
|
120
|
+
return {
|
121
|
+
connections: +String(connections[0].count || connections[0].Value) || 0,
|
122
|
+
size: +String(size[0].pg_database_size || size[0].size) || 0,
|
123
|
+
queriesPerSecond: +String(queriesPerSecond[0].sum || queriesPerSecond[0].Value) || 0,
|
72
124
|
};
|
73
125
|
}
|
74
126
|
async getUsersInfo() {
|
@@ -84,11 +136,32 @@ let CoreService = class CoreService {
|
|
84
136
|
},
|
85
137
|
},
|
86
138
|
});
|
139
|
+
const activities = await this.prismaService.user_activity.findMany({
|
140
|
+
where: {
|
141
|
+
created_at: {
|
142
|
+
gte: new Date(new Date().getTime() - 7 * 24 * 60 * 60 * 1000),
|
143
|
+
},
|
144
|
+
},
|
145
|
+
take: 10,
|
146
|
+
orderBy: {
|
147
|
+
created_at: 'desc',
|
148
|
+
},
|
149
|
+
select: {
|
150
|
+
created_at: true,
|
151
|
+
message: true,
|
152
|
+
user: {
|
153
|
+
select: {
|
154
|
+
name: true,
|
155
|
+
id: true,
|
156
|
+
},
|
157
|
+
},
|
158
|
+
},
|
159
|
+
});
|
87
160
|
return {
|
88
161
|
total: users.length,
|
89
162
|
admin: users.filter((user) => user.role_user.length > 0).length,
|
90
163
|
active: 0,
|
91
|
-
activities
|
164
|
+
activities,
|
92
165
|
};
|
93
166
|
}
|
94
167
|
async getModulesInfo() {
|
@@ -192,7 +265,7 @@ let CoreService = class CoreService {
|
|
192
265
|
const parts = lines[i].trim().split(/\s+/);
|
193
266
|
if (parts.length === 3) {
|
194
267
|
result.push({
|
195
|
-
filesystem: parts[0],
|
268
|
+
filesystem: parts[0].replace(':', ''),
|
196
269
|
size: parseInt(parts[1], 10),
|
197
270
|
free: parseInt(parts[2], 10),
|
198
271
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"core.service.js","sourceRoot":"","sources":["../../src/core/core.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+C;AAC/C,2CAA4C;AAC5C,iDAAqC;AACrC,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAGtB,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAEpD,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QACvB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACjE,MAAM,YAAY,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;QAE9C,OAAO;YACL,EAAE,EAAE;gBACF,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE;gBACvB,OAAO,EAAE,EAAE,CAAC,OAA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AAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACtB,MAAM,CAAC,IAAI,CAAC;oBACV,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;oBACpB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;oBACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;oBACd,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;oBACnB,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;oBAClB,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;iBACrB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AAzQY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEwB,sBAAa;GADrC,WAAW,CAyQvB"}
|
package/dist/emails/lib.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/emails/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOpE,eAAO,MAAM,iBAAiB,cAQ7B,CAAC;AAGF,eAAO,MAAM,sBAAsB,
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/emails/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOpE,eAAO,MAAM,iBAAiB,cAQ7B,CAAC;AAGF,eAAO,MAAM,sBAAsB,QAAS,MAAM,WAQjD,CAAC;AAGF,eAAO,MAAM,sBAAsB,cAQlC,CAAC;AAGF,eAAO,MAAM,mBAAmB,cAQ/B,CAAC;AAGF,eAAO,MAAM,qBAAqB,cAQjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,SAAU,mBAAmB,WAQ3D,CAAC"}
|
@@ -43,8 +43,8 @@ export declare class MenuController {
|
|
43
43
|
id: number;
|
44
44
|
created_at: Date;
|
45
45
|
updated_at: Date;
|
46
|
-
menu_id: number | null;
|
47
46
|
slug: string;
|
47
|
+
menu_id: number | null;
|
48
48
|
url: string | null;
|
49
49
|
order: number;
|
50
50
|
icon: string | null;
|
@@ -53,8 +53,8 @@ export declare class MenuController {
|
|
53
53
|
id: number;
|
54
54
|
created_at: Date;
|
55
55
|
updated_at: Date;
|
56
|
-
menu_id: number | null;
|
57
56
|
slug: string;
|
57
|
+
menu_id: number | null;
|
58
58
|
url: string | null;
|
59
59
|
order: number;
|
60
60
|
icon: string | null;
|
@@ -63,8 +63,8 @@ export declare class MenuController {
|
|
63
63
|
id: number;
|
64
64
|
created_at: Date;
|
65
65
|
updated_at: Date;
|
66
|
-
menu_id: number | null;
|
67
66
|
slug: string;
|
67
|
+
menu_id: number | null;
|
68
68
|
url: string | null;
|
69
69
|
order: number;
|
70
70
|
icon: string | null;
|
@@ -44,8 +44,8 @@ export declare class MenuService {
|
|
44
44
|
id: number;
|
45
45
|
created_at: Date;
|
46
46
|
updated_at: Date;
|
47
|
-
menu_id: number | null;
|
48
47
|
slug: string;
|
48
|
+
menu_id: number | null;
|
49
49
|
url: string | null;
|
50
50
|
order: number;
|
51
51
|
icon: string | null;
|
@@ -54,8 +54,8 @@ export declare class MenuService {
|
|
54
54
|
id: number;
|
55
55
|
created_at: Date;
|
56
56
|
updated_at: Date;
|
57
|
-
menu_id: number | null;
|
58
57
|
slug: string;
|
58
|
+
menu_id: number | null;
|
59
59
|
url: string | null;
|
60
60
|
order: number;
|
61
61
|
icon: string | null;
|
@@ -67,8 +67,8 @@ export declare class MenuService {
|
|
67
67
|
id: number;
|
68
68
|
created_at: Date;
|
69
69
|
updated_at: Date;
|
70
|
-
menu_id: number | null;
|
71
70
|
slug: string;
|
71
|
+
menu_id: number | null;
|
72
72
|
url: string | null;
|
73
73
|
order: number;
|
74
74
|
icon: string | null;
|
package/package.json
CHANGED
@@ -1,46 +1,48 @@
|
|
1
|
-
{
|
2
|
-
"name": "@hedhog/admin",
|
3
|
-
"version": "0.48.
|
4
|
-
"private": false,
|
5
|
-
"main": "dist/index.js",
|
6
|
-
"scripts": {
|
7
|
-
"clean": "rimraf ./dist",
|
8
|
-
"prebuild": "npm run clean",
|
9
|
-
"build": "tsc --project tsconfig.production.json",
|
10
|
-
"preprod": "npm run build && npm version patch",
|
11
|
-
"prod": "npm run build && npm publish --access public"
|
12
|
-
},
|
13
|
-
"file": [
|
14
|
-
"dist/**/*",
|
15
|
-
"src/entities/**/*.ts",
|
16
|
-
"src/migrations/**/*.ts",
|
17
|
-
"frontend/**/*.ts",
|
18
|
-
"emails/**/*.ts",
|
19
|
-
"src/**/*.ejs",
|
20
|
-
"hedhog/**/*.yaml",
|
21
|
-
"hedhog.yaml"
|
22
|
-
],
|
23
|
-
"keywords": [],
|
24
|
-
"author": "",
|
25
|
-
"license": "MIT",
|
26
|
-
"description": "",
|
27
|
-
"devDependencies": {
|
28
|
-
"@hedhog/
|
29
|
-
"@hedhog/
|
30
|
-
"@hedhog/
|
31
|
-
"@hedhog/
|
32
|
-
"@hedhog/
|
33
|
-
"@
|
34
|
-
"@nestjs/
|
35
|
-
"@nestjs/
|
36
|
-
"
|
37
|
-
"
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
"@hedhog/
|
42
|
-
"@hedhog/
|
43
|
-
"@hedhog/
|
44
|
-
"@
|
45
|
-
|
46
|
-
|
1
|
+
{
|
2
|
+
"name": "@hedhog/admin",
|
3
|
+
"version": "0.48.5",
|
4
|
+
"private": false,
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"scripts": {
|
7
|
+
"clean": "rimraf ./dist",
|
8
|
+
"prebuild": "npm run clean",
|
9
|
+
"build": "tsc --project tsconfig.production.json",
|
10
|
+
"preprod": "npm run build && npm version patch",
|
11
|
+
"prod": "npm run build && npm publish --access public"
|
12
|
+
},
|
13
|
+
"file": [
|
14
|
+
"dist/**/*",
|
15
|
+
"src/entities/**/*.ts",
|
16
|
+
"src/migrations/**/*.ts",
|
17
|
+
"frontend/**/*.ts",
|
18
|
+
"emails/**/*.ts",
|
19
|
+
"src/**/*.ejs",
|
20
|
+
"hedhog/**/*.yaml",
|
21
|
+
"hedhog.yaml"
|
22
|
+
],
|
23
|
+
"keywords": [],
|
24
|
+
"author": "",
|
25
|
+
"license": "MIT",
|
26
|
+
"description": "",
|
27
|
+
"devDependencies": {
|
28
|
+
"@hedhog/dashboard": "^0.48.1",
|
29
|
+
"@hedhog/locale": "^0.46.2",
|
30
|
+
"@hedhog/mail": "^0.48.1",
|
31
|
+
"@hedhog/pagination": "^0.46.1",
|
32
|
+
"@hedhog/prisma": "^0.46.1",
|
33
|
+
"@hedhog/utils": "^0.0.28",
|
34
|
+
"@nestjs/config": "^4.0.1",
|
35
|
+
"@nestjs/jwt": "^10.2.0",
|
36
|
+
"@nestjs/mapped-types": "^2.1.0",
|
37
|
+
"ts-node": "^10.9.1",
|
38
|
+
"typescript": "^5.1.3"
|
39
|
+
},
|
40
|
+
"peerDependencies": {
|
41
|
+
"@hedhog/dashboard": "latest",
|
42
|
+
"@hedhog/locale": "latest",
|
43
|
+
"@hedhog/pagination": "latest",
|
44
|
+
"@hedhog/prisma": "latest",
|
45
|
+
"@hedhog/utils": "latest",
|
46
|
+
"@nestjs/jwt": "^10.2.0"
|
47
|
+
}
|
48
|
+
}
|
package/src/core/core.service.ts
CHANGED
@@ -16,6 +16,7 @@ export class CoreService {
|
|
16
16
|
|
17
17
|
return {
|
18
18
|
os: {
|
19
|
+
name: this.getFriendlyOSName(),
|
19
20
|
platform: os.platform(),
|
20
21
|
version: os.release(),
|
21
22
|
architecture: os.arch(),
|
@@ -26,6 +27,60 @@ export class CoreService {
|
|
26
27
|
},
|
27
28
|
modules: await this.getModulesInfo(),
|
28
29
|
users: await this.getUsersInfo(),
|
30
|
+
database: await this.getDatabaseInfo(),
|
31
|
+
};
|
32
|
+
}
|
33
|
+
|
34
|
+
private getFriendlyOSName() {
|
35
|
+
switch (os.platform()) {
|
36
|
+
case 'aix':
|
37
|
+
return `AIX`;
|
38
|
+
case 'darwin':
|
39
|
+
return `macOS`;
|
40
|
+
case 'freebsd':
|
41
|
+
return `FreeBSD`;
|
42
|
+
case 'linux':
|
43
|
+
return `Linux`;
|
44
|
+
case 'openbsd':
|
45
|
+
return `OpenBSD`;
|
46
|
+
case 'sunos':
|
47
|
+
return `SunOS`;
|
48
|
+
case 'win32':
|
49
|
+
return `Windows`;
|
50
|
+
default:
|
51
|
+
return `Unknown`;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
private async getDatabaseInfo() {
|
56
|
+
let connections, size, queriesPerSecond;
|
57
|
+
|
58
|
+
if (process.env.DATABASE_URL.includes('postgres')) {
|
59
|
+
[connections, size, queriesPerSecond] = await Promise.all([
|
60
|
+
this.prismaService.$queryRaw`SELECT COUNT(*) FROM pg_stat_activity`, // For PostgreSQL
|
61
|
+
this.prismaService
|
62
|
+
.$queryRaw`SELECT pg_database_size(current_database())`, // For PostgreSQL
|
63
|
+
this.prismaService
|
64
|
+
.$queryRaw`SELECT sum(numbackends) FROM pg_stat_database`, // For PostgreSQL
|
65
|
+
]);
|
66
|
+
} else if (process.env.DATABASE_URL.includes('mysql')) {
|
67
|
+
[connections, size, queriesPerSecond] = await Promise.all([
|
68
|
+
this.prismaService
|
69
|
+
.$queryRaw`SHOW STATUS WHERE variable_name = 'Threads_connected'`, // For MySQL
|
70
|
+
this.prismaService
|
71
|
+
.$queryRaw`SELECT SUM(data_length + index_length) AS size FROM information_schema.tables WHERE table_schema = DATABASE()`, // For MySQL
|
72
|
+
this.prismaService
|
73
|
+
.$queryRaw`SHOW STATUS WHERE variable_name = 'Queries'`, // For MySQL
|
74
|
+
]);
|
75
|
+
} else {
|
76
|
+
throw new Error('Unsupported database type');
|
77
|
+
}
|
78
|
+
|
79
|
+
return {
|
80
|
+
connections: +String(connections[0].count || connections[0].Value) || 0,
|
81
|
+
size: +String(size[0].pg_database_size || size[0].size) || 0,
|
82
|
+
queriesPerSecond:
|
83
|
+
+String(queriesPerSecond[0].sum || queriesPerSecond[0].Value) || 0,
|
29
84
|
};
|
30
85
|
}
|
31
86
|
|
@@ -43,11 +98,33 @@ export class CoreService {
|
|
43
98
|
},
|
44
99
|
});
|
45
100
|
|
101
|
+
const activities = await this.prismaService.user_activity.findMany({
|
102
|
+
where: {
|
103
|
+
created_at: {
|
104
|
+
gte: new Date(new Date().getTime() - 7 * 24 * 60 * 60 * 1000),
|
105
|
+
},
|
106
|
+
},
|
107
|
+
take: 10,
|
108
|
+
orderBy: {
|
109
|
+
created_at: 'desc',
|
110
|
+
},
|
111
|
+
select: {
|
112
|
+
created_at: true,
|
113
|
+
message: true,
|
114
|
+
user: {
|
115
|
+
select: {
|
116
|
+
name: true,
|
117
|
+
id: true,
|
118
|
+
},
|
119
|
+
},
|
120
|
+
},
|
121
|
+
});
|
122
|
+
|
46
123
|
return {
|
47
124
|
total: users.length,
|
48
125
|
admin: users.filter((user) => user.role_user.length > 0).length,
|
49
126
|
active: 0,
|
50
|
-
activities
|
127
|
+
activities,
|
51
128
|
};
|
52
129
|
}
|
53
130
|
|
@@ -167,7 +244,7 @@ export class CoreService {
|
|
167
244
|
const parts = lines[i].trim().split(/\s+/);
|
168
245
|
if (parts.length === 3) {
|
169
246
|
result.push({
|
170
|
-
filesystem: parts[0],
|
247
|
+
filesystem: parts[0].replace(':', ''),
|
171
248
|
size: parseInt(parts[1], 10),
|
172
249
|
free: parseInt(parts[2], 10),
|
173
250
|
});
|