Skip to content

Commit 4e9254c

Browse files
author
Joan-Angelo Enrile
committed
refactor: improve iteration path handling in getIterationPathByOptions function
1 parent af19bfc commit 4e9254c

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/api/workItems.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export async function listWorkItems(
175175
}
176176

177177
if (options.iterationPath) {
178-
conditions.push(`[System.IterationPath] CONTAINS '${options.iterationPath.replace(/'/g, "''")}'`);
178+
conditions.push(`[System.IterationPath] = '${options.iterationPath.replace(/'/g, "''")}'`);
179179
}
180180

181181
const wiql = {

src/commands/issue/list.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ async function getIterationPathByOptions(connection: WebApi, project: string, it
1212
return undefined;
1313
}
1414

15+
const originalIteration = iteration;
1516
iteration = iteration.toLowerCase();
1617

1718
if (iteration === 'all') {
1819
return undefined;
1920
}
2021

21-
if (iteration !== 'current' && iteration !== 'next') {
22-
return iteration;
23-
}
2422

2523

2624
const myTeams = await getTeams(connection, project, { mine: true });
@@ -31,6 +29,15 @@ async function getIterationPathByOptions(connection: WebApi, project: string, it
3129
}
3230

3331
const team = myTeams[0].name!;
32+
const allIterations = await getTeamIterations(connection, project, team, {});
33+
34+
if (iteration !== 'current' && iteration !== 'next') {
35+
36+
const matched = allIterations.find(i => i.name?.toLowerCase() === iteration || i.path?.toLowerCase() === iteration);
37+
return matched?.path ?? originalIteration;
38+
}
39+
40+
3441
const iterations = await getTeamIterations(connection, project, team, { current: true });
3542

3643
if (iterations.length === 0) {
@@ -44,7 +51,6 @@ async function getIterationPathByOptions(connection: WebApi, project: string, it
4451
}
4552

4653
if (iteration === 'next') {
47-
const allIterations = await getTeamIterations(connection, project, team, {});
4854
const currentIndex = allIterations.findIndex(i => i.id === currentIteration.id);
4955

5056
if (currentIndex === -1 || currentIndex === allIterations.length - 1) {

0 commit comments

Comments
 (0)