feat(workload): change header
This commit is contained in:
@@ -15,12 +15,12 @@ export default function LabelWorkloadTable() {
|
||||
{ key: "object_size", title: "新增对象数" },
|
||||
{ key: "confirmed_prelabel_size", title: "确认预标注对象数" },
|
||||
{ key: "prelabel_object_size", title: "预标注对象数" },
|
||||
{ key: "commit_label_1", title: "提交标注任务数" },
|
||||
{ key: "commit_reviewed_1", title: "被审核任务数" },
|
||||
{ key: "reviewed_size", title: "被审核对象数" },
|
||||
{ key: "commented_size", title: "被批注对象数" },
|
||||
{ key: "rejected_label_1", title: "被驳回任务数" },
|
||||
{ key: "total_reviewed_size", title: "被审核过任务对象总数" },
|
||||
{ key: "commit_label_1", title: "提交标注任务数" },
|
||||
{ key: "commit_reviewed_1", title: "被审核任务数" },
|
||||
{ key: "rejected_label_1", title: "标注任务被驳回数" },
|
||||
{ key: "dynamic_size", title: "新增动态对象数" },
|
||||
{ key: "static_size", title: "新增静态对象数" },
|
||||
{ key: "key_frame_size", title: "新增关键帧数" },
|
||||
|
||||
@@ -53,6 +53,19 @@ function createInitialFilters() {
|
||||
}
|
||||
}
|
||||
|
||||
function createDimensionColumn(
|
||||
accessor: string,
|
||||
title: string,
|
||||
width: number
|
||||
): DataTableColumn<any> {
|
||||
return {
|
||||
accessor,
|
||||
title,
|
||||
width,
|
||||
sortable: true,
|
||||
}
|
||||
}
|
||||
|
||||
export default function WorkloadMetricsTable(props: {
|
||||
title: string
|
||||
sheetName: string
|
||||
@@ -144,6 +157,72 @@ export default function WorkloadMetricsTable(props: {
|
||||
return records
|
||||
}, [appliedFilters, data])
|
||||
|
||||
const getTime = (time: number) => {
|
||||
return dayjs.duration(time, "seconds").format("HH:mm:ss")
|
||||
}
|
||||
|
||||
const baseColumns = useMemo(() => {
|
||||
const allCols: Record<DimensionType, DataTableColumn<any>[]> = {
|
||||
all: [
|
||||
createDimensionColumn("uid", "用户ID", 100),
|
||||
createDimensionColumn("user_name", "用户名", 140),
|
||||
createDimensionColumn("group_name", "用户组", 160),
|
||||
createDimensionColumn("project_id", "项目ID", 120),
|
||||
createDimensionColumn("project_name", "项目名称", 180),
|
||||
createDimensionColumn("project_type", "项目类型", 320),
|
||||
createDimensionColumn("project_label_type", "标注类别", 140),
|
||||
],
|
||||
order_by_group_name: [createDimensionColumn("group_name", "用户组", 180)],
|
||||
order_by_project_name: [
|
||||
createDimensionColumn("project_name", "项目名称", 220),
|
||||
],
|
||||
order_by_project_type: [
|
||||
createDimensionColumn("project_type", "项目类型", 320),
|
||||
],
|
||||
order_by_user_name: [createDimensionColumn("user_name", "用户名", 180)],
|
||||
}
|
||||
return allCols[appliedFilters.dimension]
|
||||
}, [appliedFilters.dimension])
|
||||
|
||||
const defaultSortStatus = useMemo<DataTableSortStatus>(() => {
|
||||
const dimensionDefaultAccessorMap: Record<DimensionType, string> = {
|
||||
all: "work_time",
|
||||
order_by_group_name: "group_name",
|
||||
order_by_project_name: "project_name",
|
||||
order_by_project_type: "project_type",
|
||||
order_by_user_name: "user_name",
|
||||
}
|
||||
|
||||
const preferredAccessor =
|
||||
dimensionDefaultAccessorMap[appliedFilters.dimension] ??
|
||||
metrics[0]?.key ??
|
||||
String(baseColumns[0]?.accessor ?? "index")
|
||||
const isMetricColumn = metrics.some(
|
||||
(metric) => metric.key === preferredAccessor
|
||||
)
|
||||
|
||||
return {
|
||||
columnAccessor: preferredAccessor,
|
||||
direction: isMetricColumn ? "desc" : "asc",
|
||||
}
|
||||
}, [appliedFilters.dimension, baseColumns, metrics])
|
||||
|
||||
const availableSortAccessors = useMemo(
|
||||
() =>
|
||||
new Set([
|
||||
...baseColumns.map((column) => String(column.accessor)),
|
||||
...metrics.map((metric) => metric.key),
|
||||
]),
|
||||
[baseColumns, metrics]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (availableSortAccessors.has(String(sortStatus.columnAccessor))) {
|
||||
return
|
||||
}
|
||||
setSortStatus(defaultSortStatus)
|
||||
}, [availableSortAccessors, defaultSortStatus, sortStatus.columnAccessor])
|
||||
|
||||
const sortedRecords = useMemo(() => {
|
||||
const list = [...filteredRecords]
|
||||
const accessor = sortStatus.columnAccessor
|
||||
@@ -156,39 +235,16 @@ export default function WorkloadMetricsTable(props: {
|
||||
if (Number.isFinite(an) && Number.isFinite(bn)) {
|
||||
return (an - bn) * dir
|
||||
}
|
||||
return String(av ?? "").localeCompare(String(bv ?? "")) * dir
|
||||
return (
|
||||
String(av ?? "").localeCompare(String(bv ?? ""), "zh-CN", {
|
||||
numeric: true,
|
||||
sensitivity: "base",
|
||||
}) * dir
|
||||
)
|
||||
})
|
||||
return list
|
||||
}, [filteredRecords, sortStatus.columnAccessor, sortStatus.direction])
|
||||
|
||||
const getTime = (time: number) => {
|
||||
return dayjs.duration(time, "seconds").format("HH:mm:ss")
|
||||
}
|
||||
|
||||
const baseColumns = useMemo(() => {
|
||||
const allCols: Record<DimensionType, DataTableColumn<any>[]> = {
|
||||
all: [
|
||||
{ accessor: "project_name", title: "项目名称", width: 180 },
|
||||
{ accessor: "project_type", title: "项目类型", width: 280 },
|
||||
{ accessor: "user_name", title: "用户名", width: 120 },
|
||||
{ accessor: "group_name", title: "用户组", width: 160 },
|
||||
],
|
||||
order_by_group_name: [
|
||||
{ accessor: "group_name", title: "用户组", width: 180 },
|
||||
],
|
||||
order_by_project_name: [
|
||||
{ accessor: "project_name", title: "项目名称", width: 220 },
|
||||
],
|
||||
order_by_project_type: [
|
||||
{ accessor: "project_type", title: "项目类型", width: 320 },
|
||||
],
|
||||
order_by_user_name: [
|
||||
{ accessor: "user_name", title: "用户名", width: 180 },
|
||||
],
|
||||
}
|
||||
return allCols[appliedFilters.dimension]
|
||||
}, [appliedFilters.dimension])
|
||||
|
||||
const columns = useMemo(() => {
|
||||
const totalsByKey = Object.fromEntries(
|
||||
metrics.map((metric) => {
|
||||
@@ -268,7 +324,7 @@ export default function WorkloadMetricsTable(props: {
|
||||
const rowKey = useMemo(() => {
|
||||
if (appliedFilters.dimension === "all") {
|
||||
return (record: any) =>
|
||||
`${record.project_id ?? "p"}_${record.uid ?? "u"}_${record.project_name ?? ""}_${record.user_name ?? ""}`
|
||||
`${record.project_id ?? "p"}_${record.uid ?? "u"}_${record.project_label_type ?? ""}_${record.project_name ?? ""}_${record.user_name ?? ""}`
|
||||
}
|
||||
if (appliedFilters.dimension === "order_by_group_name") return "group_name"
|
||||
if (appliedFilters.dimension === "order_by_project_name")
|
||||
|
||||
Reference in New Issue
Block a user