fix(kanban): include archived tasks in board counts (#619)
This commit is contained in:
@@ -89,11 +89,14 @@ export async function capabilities(ctx: Context) {
|
||||
}
|
||||
|
||||
export async function list(ctx: Context) {
|
||||
const { status, assignee, tenant } = ctx.query as Record<string, string | undefined>
|
||||
const status = firstQueryValue(ctx.query.status as string | string[] | undefined)
|
||||
const assignee = firstQueryValue(ctx.query.assignee as string | string[] | undefined)
|
||||
const tenant = firstQueryValue(ctx.query.tenant as string | string[] | undefined)
|
||||
const includeArchived = firstQueryValue(ctx.query.includeArchived as string | string[] | undefined) === 'true'
|
||||
const board = requestBoard(ctx)
|
||||
if (!board) return
|
||||
try {
|
||||
const tasks = await kanbanCli.listTasks({ board, status, assignee, tenant })
|
||||
const tasks = await kanbanCli.listTasks({ board, status, assignee, tenant, includeArchived })
|
||||
ctx.body = { tasks }
|
||||
} catch (err: any) {
|
||||
ctx.status = 500
|
||||
|
||||
@@ -221,8 +221,10 @@ export async function listTasks(opts?: {
|
||||
status?: string
|
||||
assignee?: string
|
||||
tenant?: string
|
||||
includeArchived?: boolean
|
||||
}): Promise<KanbanTask[]> {
|
||||
const args = [...boardArgs(opts?.board), 'list', '--json']
|
||||
if (opts?.includeArchived) args.push('--archived')
|
||||
if (opts?.status) args.push('--status', opts.status)
|
||||
if (opts?.assignee) args.push('--assignee', opts.assignee)
|
||||
if (opts?.tenant) args.push('--tenant', opts.tenant)
|
||||
@@ -346,7 +348,13 @@ export async function getStats(opts?: KanbanBoardOptions): Promise<KanbanStats>
|
||||
timeout: 30000,
|
||||
...execOpts,
|
||||
})
|
||||
return JSON.parse(stdout)
|
||||
const stats = JSON.parse(stdout) as KanbanStats
|
||||
const archivedTasks = await listTasks({ board: opts?.board, status: 'archived', includeArchived: true })
|
||||
const existingArchived = stats.by_status?.archived || 0
|
||||
const archivedCount = archivedTasks.length
|
||||
stats.by_status = { ...(stats.by_status || {}), archived: archivedCount }
|
||||
stats.total = (stats.total || 0) + Math.max(0, archivedCount - existingArchived)
|
||||
return stats
|
||||
} catch (err: any) {
|
||||
logger.error(err, 'Hermes CLI: kanban stats failed')
|
||||
throw new Error(`Failed to get kanban stats: ${err.message}`)
|
||||
|
||||
Reference in New Issue
Block a user