增加打手列表筛选汇总
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
countTimeoutEventsByWorkerIds,
|
||||
getWorkerUserStatistics,
|
||||
getWorkerLevelById,
|
||||
listWorkerUsers,
|
||||
revokeAllWorkerSessions,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
hashWorkerPassword,
|
||||
mapWorkerUser,
|
||||
normalizeAmountFen,
|
||||
normalizeBoolean,
|
||||
normalizeOptionalId,
|
||||
normalizeReviewStatus,
|
||||
normalizeSessionVersion,
|
||||
@@ -29,15 +31,21 @@ export async function listAdminWorkerUsers(query: JsonObject = {}) {
|
||||
const pageSize = normalizePageSize(query.pageSize)
|
||||
const workerId = normalizeOptionalId(query.workerId ?? query.worker_id) || 0
|
||||
const levelId = normalizeOptionalId(query.levelId ?? query.level_id) || 0
|
||||
const { items, total } = await listWorkerUsers({
|
||||
page,
|
||||
pageSize,
|
||||
const filters = {
|
||||
workerId,
|
||||
levelId,
|
||||
status: String(query.status || '').trim(),
|
||||
keyword: String(query.keyword || '').trim(),
|
||||
workerType: String(query.workerType || query.worker_type || '').trim(),
|
||||
})
|
||||
}
|
||||
const includeStatistics = normalizeBoolean(
|
||||
query.includeStatistics ?? query.include_statistics,
|
||||
false,
|
||||
)
|
||||
const [{ items, total }, statistics] = await Promise.all([
|
||||
listWorkerUsers({ page, pageSize, ...filters }),
|
||||
includeStatistics ? getWorkerUserStatistics(filters) : Promise.resolve(undefined),
|
||||
])
|
||||
const timeoutCounts = await countTimeoutEventsByWorkerIds(items.map((item) => Number(item.id)))
|
||||
return {
|
||||
items: items.map((item) => ({
|
||||
@@ -45,6 +53,7 @@ export async function listAdminWorkerUsers(query: JsonObject = {}) {
|
||||
timeoutOrderCount: timeoutCounts.get(Number(item.id)) || 0,
|
||||
})),
|
||||
pagination: { page, pageSize, total },
|
||||
...(statistics ? { statistics } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user