pipe-kan 0.23.3 → 0.23.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pipe-kan.js +40 -17
- package/package.json +1 -1
package/dist/pipe-kan.js
CHANGED
|
@@ -601,10 +601,10 @@ function createJiraCli(opts = {}) {
|
|
|
601
601
|
console.log("Refresh children skipped; no valid parent keys");
|
|
602
602
|
return "[]";
|
|
603
603
|
}
|
|
604
|
-
const CHUNK = 50;
|
|
605
604
|
const issues = [];
|
|
606
605
|
const seen = new Set;
|
|
607
606
|
let anyFailed = false;
|
|
607
|
+
let lockedMode;
|
|
608
608
|
function buildJql(chunkKeys, mode) {
|
|
609
609
|
const list = chunkKeys.map((key) => `"${key}"`).join(", ");
|
|
610
610
|
if (mode === "epic")
|
|
@@ -613,36 +613,59 @@ function createJiraCli(opts = {}) {
|
|
|
613
613
|
return `parent in (${list})`;
|
|
614
614
|
return `(parent in (${list}) OR "Epic Link" in (${list}))`;
|
|
615
615
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
616
|
+
function chunkSizeFor(mode) {
|
|
617
|
+
return mode === "or" ? 50 : 100;
|
|
618
|
+
}
|
|
619
|
+
async function fetchChunk(chunk, chunkIndex, preferredMode) {
|
|
620
|
+
const modes = preferredMode ? [preferredMode, "or", "epic", "parent"].filter((m, i, arr) => arr.indexOf(m) === i) : ["or", "epic", "parent"];
|
|
620
621
|
let lastError;
|
|
621
622
|
for (const mode of modes) {
|
|
623
|
+
const size = chunkSizeFor(mode);
|
|
624
|
+
if (chunk.length > size)
|
|
625
|
+
continue;
|
|
622
626
|
try {
|
|
623
|
-
chunkIssues = JSON.parse(await listAll([
|
|
627
|
+
const chunkIssues = JSON.parse(await listAll([
|
|
624
628
|
"issue",
|
|
625
629
|
"list",
|
|
626
630
|
"-q",
|
|
627
631
|
buildJql(chunk, mode)
|
|
628
632
|
]));
|
|
629
|
-
|
|
633
|
+
return { issues: chunkIssues, used: mode };
|
|
630
634
|
} catch (err) {
|
|
631
635
|
lastError = err instanceof Error ? err.message : String(err);
|
|
632
636
|
}
|
|
633
637
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
638
|
+
console.log(`Refresh children chunk ${chunkIndex + 1} failed; ${lastError ?? "unknown error"}`);
|
|
639
|
+
return { issues: [], error: lastError };
|
|
640
|
+
}
|
|
641
|
+
const concurrency = 5;
|
|
642
|
+
const chunks = [];
|
|
643
|
+
let cursor = 0;
|
|
644
|
+
for (let i = 0;i < validKeys.length; i += chunkSizeFor(lockedMode ?? "or")) {
|
|
645
|
+
const size = chunkSizeFor(lockedMode ?? "or");
|
|
646
|
+
const chunk = validKeys.slice(i, i + size);
|
|
647
|
+
chunks.push({ chunk, index: cursor++ });
|
|
648
|
+
}
|
|
649
|
+
async function processChunk({ chunk, index }) {
|
|
650
|
+
const preferred = lockedMode;
|
|
651
|
+
const result = await fetchChunk(chunk, index, preferred);
|
|
652
|
+
if (result.used && !lockedMode) {
|
|
653
|
+
lockedMode = result.used;
|
|
654
|
+
}
|
|
655
|
+
if (result.error) {
|
|
643
656
|
anyFailed = true;
|
|
644
|
-
|
|
657
|
+
return;
|
|
645
658
|
}
|
|
659
|
+
for (const issue of result.issues) {
|
|
660
|
+
const key = issueKey(issue);
|
|
661
|
+
if (key && !seen.has(key)) {
|
|
662
|
+
seen.add(key);
|
|
663
|
+
issues.push(issue);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
for (let i = 0;i < chunks.length; i += concurrency) {
|
|
668
|
+
await Promise.all(chunks.slice(i, i + concurrency).map(processChunk));
|
|
646
669
|
}
|
|
647
670
|
if (anyFailed && issues.length === 0) {
|
|
648
671
|
throw new Error("Epic children fetch failed for all batches");
|