-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mis): 管理系统平台数据统计作业提交用户前十数横坐标改为userName (#1206)
### 做了什么 1.管理系统->平台数据统计->用户提交TOP10,横坐标改为userName #### 改进前 ![368260221c753d5de6ce002ca3bafd1](https://github.com/PKUHPC/SCOW/assets/72734623/b0e80829-fb2f-4526-bba0-ac3ce778920e) #### 改进后 ![ad2ee8bb6ccb1897dcd277e3bc29692](https://github.com/PKUHPC/SCOW/assets/72734623/c8081f48-3ff6-4c1f-a436-b3295c69fe91)
- Loading branch information
Showing
8 changed files
with
198 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@scow/mis-server": patch | ||
"@scow/mis-web": patch | ||
"@scow/grpc-api": patch | ||
--- | ||
|
||
管理系统下的平台数据统计提交作业前十的用户数横坐标改为以 userName 的方式显示. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
apps/mis-web/src/pages/api/admin/getUsersWithMostJobSubmissions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* Copyright (c) 2022 Peking University and Peking University Institute for Computing and Digital Economy | ||
* SCOW is licensed under Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
* See the Mulan PSL v2 for more details. | ||
*/ | ||
|
||
import { typeboxRoute, typeboxRouteSchema } from "@ddadaal/next-typed-api-routes-runtime"; | ||
import { asyncClientCall } from "@ddadaal/tsgrpc-client"; | ||
import { JobServiceClient } from "@scow/protos/build/server/job"; | ||
import { Static, Type } from "@sinclair/typebox"; | ||
import { authenticate } from "src/auth/server"; | ||
import { PlatformRole } from "src/models/User"; | ||
import { getClient } from "src/utils/client"; | ||
|
||
export const GetUsersWithMostJobSubmissionsResponse = Type.Object({ | ||
results: Type.Array(Type.Object({ | ||
userName: Type.String(), | ||
userId:Type.String(), | ||
count: Type.Number(), | ||
})), | ||
}); | ||
|
||
// 定义错误相应类型 | ||
export const ErrorResponse = Type.Object({ | ||
message: Type.String(), | ||
}); | ||
|
||
export type GetUsersWithMostJobSubmissionsResponse = Static<typeof GetUsersWithMostJobSubmissionsResponse>; | ||
|
||
|
||
export const GetUsersWithMostJobSubmissionsSchema = typeboxRouteSchema({ | ||
method: "GET", | ||
|
||
query: Type.Object({ | ||
|
||
startTime: Type.String({ format: "date-time" }), | ||
|
||
endTime: Type.String({ format: "date-time" }), | ||
|
||
// 最大为10,不传默认为10 | ||
topNUsers: Type.Optional(Type.Number()), | ||
|
||
}), | ||
|
||
responses: { | ||
200: GetUsersWithMostJobSubmissionsResponse, | ||
400: ErrorResponse, | ||
}, | ||
}); | ||
|
||
const auth = authenticate((info) => info.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)); | ||
|
||
export default typeboxRoute(GetUsersWithMostJobSubmissionsSchema, | ||
async (req, res) => { | ||
|
||
const info = await auth(req, res); | ||
if (!info) { | ||
return; | ||
} | ||
|
||
|
||
const { startTime, endTime, topNUsers } = req.query; | ||
// 检查 topNUsers 是否符合要求 | ||
if (typeof topNUsers == "number" && (topNUsers > 10 || topNUsers < 0)) { | ||
res.status(400).send({ message: "Parameter topNUsers must be between 0 and 10." }); | ||
return; | ||
}; | ||
|
||
const client = getClient(JobServiceClient); | ||
|
||
const { results } = await asyncClientCall(client, "getUsersWithMostJobSubmissions", { | ||
startTime, | ||
endTime, | ||
topNUsers, | ||
}); | ||
|
||
return { | ||
200: { | ||
results, | ||
}, | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters