Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions models/tracker/src/viewlets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ import tracker from './plugin'
// (List + Kanban) and the Gantt viewlet block. Keep this list as the single
// source of truth so a change in one place can never disagree with the
// other half of the UI.
const showEstimationSumViewOption: ViewOptionModel = {
key: 'showEstimationSum',
type: 'toggle',
defaultValue: false,
actionTarget: 'display',
label: tracker.string.ShowEstimationSum
}

const SEARCH_VIEW_OPTIONS: ViewOptionModel[] = [
{
key: 'showQuickModeSelector',
Expand Down Expand Up @@ -107,7 +115,7 @@ export const issuesOptions = (kanban: boolean): ViewOptionsModel => ({
action: view.function.HideArchived,
label: view.string.HideArchived
},
...(!kanban ? [showColorsViewOption] : []),
...(!kanban ? [showColorsViewOption, showEstimationSumViewOption] : []),
...SEARCH_VIEW_OPTIONS
]
})
Expand Down Expand Up @@ -670,7 +678,7 @@ export function defineViewlets (builder: Builder): void {
['dueDate', SortingOrder.Ascending]
],
groupDepth: 1,
other: [showColorsViewOption]
other: [showColorsViewOption, showEstimationSumViewOption]
}

builder.createDoc(
Expand Down Expand Up @@ -712,7 +720,7 @@ export function defineViewlets (builder: Builder): void {
['dueDate', SortingOrder.Ascending]
],
groupDepth: 1,
other: [showColorsViewOption]
other: [showColorsViewOption, showEstimationSumViewOption]
}

builder.createDoc(
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
"TimeSpendHours": "{value}h",
"TimeSpendMinutes": "{value}m",
"ChildEstimation": "Odhad podúkolů",
"ShowEstimationSum": "Zobrazit součet odhadů ve skupinách",
"ChildReportedTime": "Čas podúkolů",
"CapacityValue": "z {value}d",
"NewRelatedIssue": "Nový související úkol",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@
"TimeSpendHours": "{value}Std",
"TimeSpendMinutes": "{value}Min",
"ChildEstimation": "Schätzung Unteraufgaben",
"ShowEstimationSum": "Summe der Schätzungen in Gruppen anzeigen",
"ChildReportedTime": "Zeit Unteraufgaben",
"CapacityValue": "von {value}T",
"NewRelatedIssue": "Neue verwandte Aufgabe",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"TimeSpendHours": "{value}h",
"TimeSpendMinutes": "{value}m",
"ChildEstimation": "Sub-issues estimation",
"ShowEstimationSum": "Show estimation sum in groups",
"ChildReportedTime": "Sub-issues time",
"CapacityValue": "of {value}d",
"NewRelatedIssue": "New related issue",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"TimeSpendHours": "{value}h",
"TimeSpendMinutes": "{value}m",
"ChildEstimation": "Estimación de subtemas",
"ShowEstimationSum": "Mostrar la suma de estimaciones en los grupos",
"ChildReportedTime": "Tiempo de subtemas",
"CapacityValue": "de {value}d",
"NewRelatedIssue": "Nuevo problema relacionado",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"TimeSpendHours": "{value}h",
"TimeSpendMinutes": "{value}m",
"ChildEstimation": "Estimation des sous-problèmes",
"ShowEstimationSum": "Afficher la somme des estimations dans les groupes",
"ChildReportedTime": "Temps des sous-problèmes",
"CapacityValue": "de {value}j",
"NewRelatedIssue": "Nouvelle issue liée",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"TimeSpendHours": "{value}h",
"TimeSpendMinutes": "{value}m",
"ChildEstimation": "Stima delle subissue",
"ShowEstimationSum": "Mostra la somma delle stime nei gruppi",
"ChildReportedTime": "Tempo delle subissue",
"CapacityValue": "di {value}d",
"NewRelatedIssue": "Nuova issue correlata",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"TimeSpendHours": "{value}時間",
"TimeSpendMinutes": "{value}分",
"ChildEstimation": "子イシューの見積もり",
"ShowEstimationSum": "グループに見積もりの合計を表示",
"ChildReportedTime": "子イシューの時間",
"CapacityValue": "うち {value}日",
"NewRelatedIssue": "新しい関連イシュー",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"TimeSpendHours": "{value}시간",
"TimeSpendMinutes": "{value}분",
"ChildEstimation": "하위 이슈 예상치",
"ShowEstimationSum": "그룹에 예상치 합계 표시",
"ChildReportedTime": "하위 이슈 시간",
"CapacityValue": "{value}일 중",
"NewRelatedIssue": "새 관련 이슈",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"TimeSpendHours": "{value, plural, =1 {1 godzina} few {# godziny} many {# godzin} other {# godziny}}",
"TimeSpendMinutes": "{value, plural, =1 {1 minuta} few {# minuty} many {# minut} other {# minuty}}",
"ChildEstimation": "Wycena podzagadnień",
"ShowEstimationSum": "Pokaż sumę wycen w grupach",
"ChildReportedTime": "Czas poświęcony na podzagadnienia",
"CapacityValue": "z {value, plural, =1 {1 dnia} other {# dni}}",
"NewRelatedIssue": "Nowe powiązane zadanie",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"TimeSpendHours": "{value}h",
"TimeSpendMinutes": "{value}m",
"ChildEstimation": "Estimativa de sub-tarefas",
"ShowEstimationSum": "Mostrar a soma das estimativas nos grupos",
"ChildReportedTime": "Tempo de sub-tarefas",
"CapacityValue": "de {value}d",
"NewRelatedIssue": "Nova tarefa relacionada",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"TimeSpendHours": "{value}h",
"TimeSpendMinutes": "{value}m",
"ChildEstimation": "Estimativa de sub-tarefas",
"ShowEstimationSum": "Mostrar a soma das estimativas nos grupos",
"ChildReportedTime": "Tempo de sub-tarefas",
"CapacityValue": "de {value}d",
"NewRelatedIssue": "Nova tarefa relacionada",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"TimeSpendHours": "{value} ч",
"TimeSpendMinutes": "{value} м",
"ChildEstimation": "Оценка подзадач",
"ShowEstimationSum": "Показывать сумму оценок в группах",
"ChildReportedTime": "Время подзадач",
"CapacityValue": "из {value} д",
"NewRelatedIssue": "Завести связанную задачу",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
"TimeSpendHours": "{value}s",
"TimeSpendMinutes": "{value}dk",
"ChildEstimation": "Alt sorunlar tahmini",
"ShowEstimationSum": "Gruplarda tahmin toplamını göster",
"ChildReportedTime": "Alt sorunlar zamanı",
"CapacityValue": "{value}g üzerinden",
"NewRelatedIssue": "Yeni ilgili sorun",
Expand Down
1 change: 1 addition & 0 deletions plugins/tracker-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
"TimeSpendHours": "{value} 小时",
"TimeSpendMinutes": "{value} 分钟",
"ChildEstimation": "子问题估算",
"ShowEstimationSum": "在分组中显示估算总和",
"ChildReportedTime": "子问题时间",
"CapacityValue": "共 {value} 天",
"NewRelatedIssue": "新相关问题",
Expand Down
189 changes: 189 additions & 0 deletions plugins/tracker-resources/src/__tests__/issueTimeStats.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
//
// Copyright © 2026 Hardcore Engineering Inc.
// SPDX-License-Identifier: EPL-2.0
//

import {
calcIssueTimeStats,
calcPlanningIssueTimeStats,
type IssueTimeInfo,
type IssueTimeStatsOptions
} from '../issueTimeStats'

function issue (
id: string,
status: string,
estimation: number,
reportedTime: number,
parents: string[] = [],
children: Array<{ childId: string, estimation: number, reportedTime: number }> = []
): IssueTimeInfo {
return {
_id: id as any,
attachedTo: (parents[parents.length - 1] ?? 'no-parent') as any,
parents: parents.map((parentId) => ({ parentId }) as any),
status: status as any,
estimation,
reportedTime,
childInfo: children as any
}
}

const options = (skipUnStarted: boolean, includeAllChildren = false): IssueTimeStatsOptions<IssueTimeInfo> => ({
isUnStarted: (it) => it.status === 'backlog',
isClosed: (it) => it.status === 'done' || it.status === 'canceled',
skipUnStarted,
includeAllChildren
})

describe('calcIssueTimeStats', () => {
it('returns zero for an empty group', () => {
expect(calcIssueTimeStats([], options(false))).toEqual({ estimation: 0, reportedTime: 0 })
})

it('sums estimation and reported time of plain issues', () => {
const docs = [issue('a', 'todo', 2, 1), issue('b', 'todo', 3, 0.5)]
expect(calcIssueTimeStats(docs, options(false))).toEqual({ estimation: 5, reportedTime: 1.5 })
})

it('counts backlog issues unless skipUnStarted is set', () => {
const docs = [issue('a', 'backlog', 4, 0), issue('b', 'todo', 1, 0)]
expect(calcIssueTimeStats(docs, options(false)).estimation).toBe(5)
expect(calcIssueTimeStats(docs, options(true)).estimation).toBe(1)
})

it('does not count a sub-issue twice when its parent is in the same group', () => {
const parent = issue(
'p',
'todo',
10,
1,
[],
[
{ childId: 'c1', estimation: 2, reportedTime: 1 },
{ childId: 'c2', estimation: 3, reportedTime: 0 }
]
)
const c1 = issue('c1', 'todo', 2, 1, ['p'])
const c2 = issue('c2', 'todo', 3, 0, ['p'])
expect(calcIssueTimeStats([parent, c1, c2], options(false))).toEqual({ estimation: 5, reportedTime: 2 })
})

it('leaves time of sub-issues listed in another group to that group', () => {
const parent = issue(
'p',
'todo',
10,
1,
[],
[
{ childId: 'c1', estimation: 2, reportedTime: 1 },
{ childId: 'c2', estimation: 3, reportedTime: 4 }
]
)
const c1 = issue('c1', 'todo', 2, 1, ['p'])
const c2 = issue('c2', 'done', 3, 4, ['p'])
// Group A holds the parent and c1, group B holds c2 only.
const a = calcIssueTimeStats([parent, c1], options(false))
const b = calcIssueTimeStats([c2], options(false))
expect(a).toEqual({ estimation: 2, reportedTime: 2 })
expect(b).toEqual({ estimation: 3, reportedTime: 4 })
})

it('uses own time of a parent whose sub-issues are all in other groups', () => {
const parent = issue('p', 'todo', 10, 1, [], [{ childId: 'c1', estimation: 2, reportedTime: 1 }])
expect(calcIssueTimeStats([parent], options(false))).toEqual({ estimation: 10, reportedTime: 1 })
})

it('counts all sub-issues through the parent when sub-issues are not listed', () => {
const parent = issue(
'p',
'todo',
10,
1,
[],
[
{ childId: 'c1', estimation: 2, reportedTime: 1 },
{ childId: 'c2', estimation: 3, reportedTime: 0 }
]
)
expect(calcIssueTimeStats([parent], options(false, true))).toEqual({ estimation: 5, reportedTime: 2 })
})

it('skips a nested sub-issue whose ancestor is in the group', () => {
const root = issue(
'r',
'todo',
0,
0,
[],
[
{ childId: 'm', estimation: 0, reportedTime: 0 },
{ childId: 'g', estimation: 4, reportedTime: 1 }
]
)
// The intermediate parent 'm' is in another group.
const grandChild = issue('g', 'todo', 4, 1, ['r', 'm'])
expect(calcIssueTimeStats([root, grandChild], options(false))).toEqual({ estimation: 4, reportedTime: 1 })
})

it('counts a sub-issue whose parent is in another group', () => {
const child = issue('c', 'todo', 2, 1, ['p'])
expect(calcIssueTimeStats([child], options(false))).toEqual({ estimation: 2, reportedTime: 1 })
})

it('keeps parent estimation when sub-issues are not estimated', () => {
const parent = issue('p', 'todo', 8, 0, [], [{ childId: 'c', estimation: 0, reportedTime: 0 }])
const child = issue('c', 'todo', 0, 0, ['p'])
expect(calcIssueTimeStats([parent, child], options(false)).estimation).toBe(8)
})

it('caps estimation of closed issues by reported time', () => {
const docs = [
issue('a', 'done', 5, 2),
issue('b', 'canceled', 1, 3),
issue('p', 'done', 0, 0, [], [{ childId: 'c', estimation: 6, reportedTime: 4 }]),
issue('c', 'done', 6, 4, ['p'])
]
expect(calcIssueTimeStats(docs, options(false))).toEqual({ estimation: 2 + 1 + 4, reportedTime: 2 + 3 + 4 })
})
})

describe('calcPlanningIssueTimeStats', () => {
it('returns zero for an empty loaded page', () => {
expect(calcPlanningIssueTimeStats([], options(true))).toEqual({ estimation: 0, reportedTime: 0 })
})

it('counts all children even outside the page and preserves a larger parent estimate only for zero child estimation', () => {
const parent = issue('p', 'todo', 10, 1, [], [{ childId: 'c', estimation: 2, reportedTime: 3 }])
expect(calcPlanningIssueTimeStats([parent], options(true))).toEqual({ estimation: 2, reportedTime: 4 })
const zeroChildren = issue('p', 'todo', 10, 1, [], [{ childId: 'c', estimation: 0, reportedTime: 3 }])
expect(calcPlanningIssueTimeStats([zeroChildren], options(true))).toEqual({ estimation: 10, reportedTime: 4 })
})

it('suppresses loaded direct children but preserves the historical missing-direct-parent case', () => {
const root = issue('r', 'todo', 10, 1, [], [{ childId: 'g', estimation: 4, reportedTime: 2 }])
const grandchild = issue('g', 'todo', 4, 2, ['r', 'm'])
expect(calcPlanningIssueTimeStats([root, grandchild], options(true))).toEqual({ estimation: 8, reportedTime: 5 })
expect(calcPlanningIssueTimeStats([root, issue('m', 'todo', 0, 0, ['r']), grandchild], options(true))).toEqual({
estimation: 4,
reportedTime: 3
})
})

it('keeps own and child reported time for backlog roots', () => {
const parent = issue('p', 'backlog', 10, 1, [], [{ childId: 'c', estimation: 2, reportedTime: 3 }])
expect(calcPlanningIssueTimeStats([parent], options(true))).toEqual({ estimation: 0, reportedTime: 4 })
})

it.each(['done', 'canceled'])('preserves all historical %s cap branches', (status) => {
const docs = [
issue('a', status, 5, 2),
issue('b', status, 1, 3),
issue('c', status, 10, 8, [], [{ childId: 'x', estimation: 6, reportedTime: 3 }]),
issue('d', status, 10, 1, [], [{ childId: 'y', estimation: 2, reportedTime: 4 }]),
issue('e', status, 8, 1, [], [{ childId: 'z', estimation: 0, reportedTime: 2 }])
]
expect(calcPlanningIssueTimeStats(docs, options(true))).toEqual({ estimation: 16, reportedTime: 24 })
})
})
Loading
Loading