Skip to content

Commit

Permalink
feat(mis-web): 管理系统用户可见分区页面加载过慢 (#826)
Browse files Browse the repository at this point in the history
### 改动了什么

原来用户可见分区查询时前端做到了并发查询集群但是串行查询了账户
现在改动成账户传递时利用Promise.All()进行并行查询

测试结果原来58集群,16个账户两个集群查询时可能需要8秒多,现在3秒以内

![image](https://github.com/PKUHPC/SCOW/assets/43978285/aa3fee3e-6eae-4de7-99bc-4458bff31174)
  • Loading branch information
piccaSun authored Aug 25, 2023
1 parent 945bbb5 commit 8f0e51b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-eggs-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/mis-web": patch
---

管理系统用户可见分区查询时账户遍历时更改为 Promise.All()节省查询时间
33 changes: 17 additions & 16 deletions apps/mis-web/src/pages/api/job/getBillingTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,24 @@ export async function getAvailablePartitionForItems(
if (!accountNames) { return {}; }

const clusterPartitionsMap: { [cluster: string]: Partition[] } = {};
for (const accountName of accountNames) {

const availableCPs = await asyncClientCall(client, "getAvailablePartitions",
{ accountName: accountName, userId: userId }).then((resp) => {
return resp.clusterPartitions;
});
availableCPs.forEach((cp) => {

const cluster = cp.cluster;
if (!(cluster in clusterPartitionsMap)) {
clusterPartitionsMap[cluster] = [];
}
if (cp.partitions) {
clusterPartitionsMap[cluster] = clusterPartitionsMap[cluster].concat(cp.partitions);
}
});
}
await Promise.all(accountNames
.map(async (accountName) => {
const availableCPs = await asyncClientCall(client, "getAvailablePartitions",
{ accountName: accountName, userId: userId }).then((resp) => {
return resp.clusterPartitions;
});
availableCPs.forEach((cp) => {

const cluster = cp.cluster;
if (!(cluster in clusterPartitionsMap)) {
clusterPartitionsMap[cluster] = [];
}
if (cp.partitions) {
clusterPartitionsMap[cluster] = clusterPartitionsMap[cluster].concat(cp.partitions);
}
});
}));

for (const cluster of Object.keys(clusterPartitionsMap)) {
clusterPartitionsMap[cluster] = removeDuplicatesByPName(clusterPartitionsMap[cluster]);
Expand Down

0 comments on commit 8f0e51b

Please sign in to comment.