mirror of https://github.com/halo-dev/halo
refactor: add chunked execution mechanism for notification batch deletions (#7634)
#### What type of PR is this? /area ui /kind improvement /milestone 2.21.x #### What this PR does / why we need it: Use `Promise.all` to execute part of the batch deletion logic of the notification in chunks to optimize the execution performance. #### Which issue(s) this PR fixes: Fixes # #### Does this PR introduce a user-facing change? ```release-note 优化通知批量删除的执行性能 ```pull/7640/head
parent
5bb7b2826e
commit
471195d6b0
|
@ -16,6 +16,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { useRouteQuery } from "@vueuse/router";
|
||||
import { chunk } from "lodash-es";
|
||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||
import { computed } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -78,12 +79,16 @@ function handleDeleteNotifications() {
|
|||
throw new Error("Current user is not found");
|
||||
}
|
||||
|
||||
for (const notification of notifications.value.items) {
|
||||
await ucApiClient.notification.notification.deleteSpecifiedNotification(
|
||||
{
|
||||
const notificationChunks = chunk(notifications.value.items, 5);
|
||||
|
||||
for (const chunk of notificationChunks) {
|
||||
await Promise.all(
|
||||
chunk.map((notification) =>
|
||||
ucApiClient.notification.notification.deleteSpecifiedNotification({
|
||||
username: currentUser.metadata.name,
|
||||
name: notification.metadata.name,
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue