-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix release pagination issue, allow finding parentId when multiple re…
…leases exits for an iteration
- Loading branch information
Showing
5 changed files
with
69 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { detailedLogger } from "../../logger/logger_instance.js"; | ||
|
||
function extractParentId(issue, releaseIssues) { | ||
const matchingReleases = | ||
releaseIssues?.filter((release) => { | ||
return release.title.includes(`[Release ${issue.iteration}]`); | ||
}) || []; | ||
|
||
if (matchingReleases.length > 1) { | ||
detailedLogger.warning( | ||
`Multiple release issues found for iteration [Release ${issue.iteration}]. Using first match. Matches: ${matchingReleases | ||
.map((r) => r.title) | ||
.join(", ")}`, | ||
); | ||
} | ||
|
||
const parentId = matchingReleases[0]?.id || undefined; | ||
|
||
return parentId; | ||
} | ||
|
||
export default extractParentId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,42 @@ | ||
import linearClient from "../../config/client.mjs"; | ||
|
||
async function fetchIssuesForTeam({ teamId, filters }) { | ||
// Construct the filter object | ||
const filter = {}; | ||
if (teamId) filter.team = { id: { eq: teamId } }; | ||
if (filters) Object.assign(filter, filters); | ||
|
||
// Query issues with the constructed filter | ||
const filteredIssues = await linearClient.issues({ | ||
filter, | ||
// first: 100 | ||
}); | ||
|
||
let issues = []; | ||
|
||
if (filteredIssues.nodes.length) { | ||
filteredIssues.nodes.forEach((issue) => { | ||
// console.log("FULL issue", issue) | ||
const data = { | ||
id: issue.id, | ||
identifier: issue.identifier, | ||
title: issue.title, | ||
createdAt: issue.createdAt, | ||
}; | ||
let allIssues = []; | ||
let hasNextPage = true; | ||
let endCursor = null; | ||
|
||
issues.push(data); | ||
while (hasNextPage) { | ||
const filteredIssues = await linearClient.issues({ | ||
filter, | ||
first: 100, | ||
after: endCursor, | ||
}); | ||
|
||
return issues; | ||
if (filteredIssues.nodes.length) { | ||
filteredIssues.nodes.forEach((issue) => { | ||
const data = { | ||
id: issue.id, | ||
identifier: issue.identifier, | ||
title: issue.title, | ||
createdAt: issue.createdAt, | ||
}; | ||
allIssues.push(data); | ||
}); | ||
} | ||
|
||
hasNextPage = filteredIssues.pageInfo.hasNextPage; | ||
endCursor = filteredIssues.pageInfo.endCursor; | ||
} | ||
|
||
if (allIssues.length) { | ||
return allIssues; | ||
} else { | ||
console.log("No issues found matching the criteria"); | ||
} | ||
} | ||
|
||
// fetchIssuesForTeam({ teamId: '9d138c4f-fe54-4692-b775-ac6413ecd727', labelId: 'a1940aec-35b4-43a4-b6ad-21c03b2559c2'}) | ||
export default fetchIssuesForTeam; | ||
|
||
// import linearClient from "../../config/client.mjs"; | ||
// import chalk from "chalk"; | ||
|
||
// async function getMyIssues() { | ||
// const me = await linearClient.viewer; | ||
// console.log(chalk.green("me:", me.displayName)); | ||
// console.log(chalk.yellow("Getting my issues...")); | ||
// const myIssues = await me.assignedIssues(); | ||
|
||
// if (myIssues.nodes.length) { | ||
// myIssues.nodes.map((issue) => | ||
// console.log(`${issue.identifier} - ${issue.title}`), | ||
// ); | ||
// } else { | ||
// console.log(`${me.displayName} has no issues`); | ||
// } | ||
// } | ||
|
||
// getMyIssues(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters