Skip to content

Commit 17b7727

Browse files
committed
update jira status script
1 parent fe86792 commit 17b7727

File tree

1 file changed

+2
-54
lines changed

1 file changed

+2
-54
lines changed

utils/jira.js

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Jira {
7979
const transitionInfo = {
8080
id: transition.id,
8181
name: transition.name,
82-
from: transition.from || [], // Array of source status IDs
82+
from: transition.from || [],
8383
to: transition.to, // Target status ID
8484
type: transition.type || 'directed',
8585
hasScreen: transition.hasScreen || false,
@@ -88,9 +88,7 @@ class Jira {
8888

8989
stateMachine.transitions.push(transitionInfo)
9090

91-
// Build transition map for quick lookup
9291
const fromStatuses = transitionInfo.from.length > 0 ? transitionInfo.from : Object.keys(stateMachine.states)
93-
9492
fromStatuses.forEach(fromStatus => {
9593
if (!stateMachine.transitionMap.has(fromStatus)) {
9694
stateMachine.transitionMap.set(fromStatus, new Map())
@@ -217,6 +215,7 @@ class Jira {
217215
console.log(`\n=== WORKFLOW: ${stateMachine.name} ===`)
218216

219217
console.log('\n--- STATES ---')
218+
console.log(JSON.stringify(stateMachine))
220219
for (const [id, state] of Object.entries(stateMachine.states)) {
221220
console.log(` [${id}] ${state.name} (${state.statusCategory.name})`)
222221
}
@@ -421,57 +420,6 @@ class Jira {
421420
}
422421
}
423422

424-
/**
425-
* Build a complete transition graph by analyzing multiple issues
426-
* @param {number} sampleSize - Number of issues to analyze
427-
* @returns {Promise<Map>} Transition graph
428-
*/
429-
async buildTransitionGraph(sampleSize = 50) {
430-
try {
431-
// Graph structure: Map<fromStatus, Map<toStatus, transitionId>>
432-
const transitionGraph = new Map()
433-
434-
let jql = `order by created DESC`
435-
if (this.projectKey) {
436-
jql = `project = ${this.projectKey} AND ${jql}`
437-
}
438-
439-
const response = await this.request('/search', {
440-
method: 'POST',
441-
body: JSON.stringify({
442-
jql,
443-
fields: ['key', 'status'],
444-
maxResults: sampleSize
445-
})
446-
})
447-
448-
const data = await response.json()
449-
const issues = data.issues
450-
451-
// For each issue, get available transitions
452-
for (const issue of issues) {
453-
const currentStatus = issue.fields.status.name
454-
const transitions = await this.getTransitions(issue.key)
455-
456-
if (!transitionGraph.has(currentStatus)) {
457-
transitionGraph.set(currentStatus, new Map())
458-
}
459-
460-
const statusTransitions = transitionGraph.get(currentStatus)
461-
462-
for (const transition of transitions) {
463-
const toStatus = transition.to.name
464-
statusTransitions.set(toStatus, transition.id)
465-
}
466-
}
467-
468-
return transitionGraph
469-
} catch (error) {
470-
console.error(`Error building transition graph:`, error.message)
471-
throw error
472-
}
473-
}
474-
475423
/**
476424
* Find the shortest path of transitions between two statuses
477425
* @param {Map} transitionGraph - The complete transition graph

0 commit comments

Comments
 (0)