fix(kanban): include archived tasks in board counts (#619)
This commit is contained in:
@@ -143,6 +143,7 @@ export interface KanbanListOptions extends KanbanBoardOptions {
|
||||
status?: string
|
||||
assignee?: string
|
||||
tenant?: string
|
||||
includeArchived?: boolean
|
||||
}
|
||||
|
||||
function normalizedBoard(board?: string): string {
|
||||
@@ -194,6 +195,7 @@ export async function listTasks(opts?: KanbanListOptions): Promise<KanbanTask[]>
|
||||
if (opts?.status) params.set('status', opts.status)
|
||||
if (opts?.assignee) params.set('assignee', opts.assignee)
|
||||
if (opts?.tenant) params.set('tenant', opts.tenant)
|
||||
if (opts?.includeArchived) params.set('includeArchived', 'true')
|
||||
const res = await request<{ tasks: KanbanTask[] }>(appendQuery('/api/hermes/kanban', params))
|
||||
return res.tasks
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ export const useKanbanStore = defineStore('kanban', () => {
|
||||
board,
|
||||
status: filterStatus.value || undefined,
|
||||
assignee: filterAssignee.value || undefined,
|
||||
includeArchived: true,
|
||||
})
|
||||
if (isCurrentRequest(seq, generation, board, tasksRequestSeq)) tasks.value = nextTasks
|
||||
} catch (err) {
|
||||
|
||||
@@ -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