mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-12 15:20:44 +08:00
优化任务进度排序逻辑,加入节目状态、播出进度、节目总集数等多级比较
- 进度排序(by=progress)改为四层比较,且全部随升/降序方向变化: 1) 任务进度百分比(已转存/已播出) 2) 节目状态优先级:播出中/无 < 本季终 < 已取消 < 已完结 3) 播出进度百分比(已播出/总集数),在相同进度下进一步排序 3.1) 若百分比也相同,则按总集数比较(例如 12/12 < 22/22 < 36/36) 4) 任务编号(#XX),用于完全相同时的最终稳定排序 - 状态取值沿用现有逻辑:仅显示并参与排序的状态为「本季终 / 已取消 / 已完结」,其余视为 “无状态” - 保持与现有数据源兼容:进度、状态与播出统计基于 calendar.tasks/season_counts 及映射函数获取 - 所有层级比较通过统一 factor 输出,确保与用户选择的升/降序一致
This commit is contained in:
parent
240a069a08
commit
efc7e17075
@ -3877,7 +3877,60 @@
|
||||
} else if (by === 'progress') {
|
||||
const ap = (this.getTaskProgress && this.getTaskProgress(a.t.taskname) != null) ? Number(this.getTaskProgress(a.t.taskname)) : -1;
|
||||
const bp = (this.getTaskProgress && this.getTaskProgress(b.t.taskname) != null) ? Number(this.getTaskProgress(b.t.taskname)) : -1;
|
||||
cmp = ap - bp;
|
||||
// 1) 主排序:任务进度(支持升降序)
|
||||
const pDiff = ap - bp;
|
||||
if (pDiff !== 0) {
|
||||
cmp = pDiff;
|
||||
} else {
|
||||
// 2) 次排序:节目状态优先级(与主排序方向一致,通过最终 factor 生效)
|
||||
const getStatusPriority = (task) => {
|
||||
try {
|
||||
// 任务对象可能为任务配置,需要先从日历任务映射中取状态
|
||||
const calTask = this.getCalendarTaskByName(task && (task.taskname || task.task_name));
|
||||
const status = this.getTaskShowStatus(calTask || task) || '';
|
||||
if (status === '本季终') return 1;
|
||||
if (status === '已取消') return 2;
|
||||
if (status === '已完结') return 3;
|
||||
return 0; // 播出中/无状态
|
||||
} catch (e) { return 0; }
|
||||
};
|
||||
const aStatus = getStatusPriority(a.t);
|
||||
const bStatus = getStatusPriority(b.t);
|
||||
const sDiff = aStatus - bStatus;
|
||||
if (sDiff !== 0) {
|
||||
cmp = sDiff; // 顺序:播出中/无 < 本季终 < 已取消 < 已完结(方向由最终 factor 决定)
|
||||
} else {
|
||||
// 3) 三次排序:节目的播出进度(已播出/总集数),与主排序同方向
|
||||
const getBroadcastPct = (task) => {
|
||||
try {
|
||||
const calTask = this.getCalendarTaskByName(task && (task.taskname || task.task_name));
|
||||
const aired = this.getTaskAiredCount(calTask || {});
|
||||
const total = this.getTaskTotalCount(calTask || {});
|
||||
if (!total || total <= 0) return 0;
|
||||
return aired / total;
|
||||
} catch (e) { return 0; }
|
||||
};
|
||||
const aPct = getBroadcastPct(a.t);
|
||||
const bPct = getBroadcastPct(b.t);
|
||||
const pctDiff = aPct - bPct;
|
||||
if (pctDiff !== 0) {
|
||||
cmp = pctDiff;
|
||||
} else {
|
||||
// 3.1) 百分比也相同:按节目总集数排序(与主排序同方向)
|
||||
const aTotal = this.getTaskTotalCount(this.getCalendarTaskByName(a.t && (a.t.taskname || a.t.task_name)) || {});
|
||||
const bTotal = this.getTaskTotalCount(this.getCalendarTaskByName(b.t && (b.t.taskname || b.t.task_name)) || {});
|
||||
const totalDiff = aTotal - bTotal;
|
||||
if (totalDiff !== 0) {
|
||||
cmp = totalDiff;
|
||||
} else {
|
||||
// 4) 末级排序:任务编号(#XX),与主排序同方向
|
||||
const aNum = parseInt((a.t.taskname || '').match(/^#?(\d+)/)?.[1] || '0');
|
||||
const bNum = parseInt((b.t.taskname || '').match(/^#?(\d+)/)?.[1] || '0');
|
||||
cmp = aNum - bNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (by === 'update_time') {
|
||||
// 按任务最近转存时间排序
|
||||
const aRecord = this.taskLatestRecords[a.t.taskname];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user