Files
superwork/vscode/webview-ui/src/lib/issueSort.ts
T
cruldra 73f2c3ec66 🐛 fix(vscode): 完成列缺 PR 合并时间时按工单关闭时间排序
没走 PR 流程、直接关掉的工单没有 merged_at,原先一律排在所有已合并
工单之后,在上百张卡的完成列里等于永远看不见。loader 把 Gitea issue
的 closed_at 带进 Issue,完成列排序缺 prMergedAt 时回退到它,让两类
工单落在同一条时间线上。
2026-09-20 17:23:25 +08:00

28 lines
898 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { Issue, IssueColumn } from '../types'
/**
* 看板每一列的卡片排序。
*
* `done` 列按"完成时间"降序,最近完成的在最前。完成时间取 PR 合并时间
* (merged_at),没有 PR 的工单退回工单关闭时间(closed_at)——不这样兜底,
* 直接关掉、没走 PR 流程的工单会永远沉在列底看不见。两者都没有的排最后,
* 按工单号降序。其余列一律按工单号降序。
*/
function doneAt(issue: Issue): string | undefined {
return issue.prMergedAt ?? issue.closedAt
}
export function compareIssuesInColumn(col: IssueColumn, a: Issue, b: Issue): number {
if (col === 'done') {
const am = doneAt(a)
const bm = doneAt(b)
if (am && bm && am !== bm)
return bm.localeCompare(am)
if (am && !bm)
return -1
if (bm && !am)
return 1
}
return b.number - a.number
}