mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 02:26:12 +02:00
fix(pr-gardening): deduplicate truncation metadata
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
a8814a87db
commit
7f7e25b268
2 files changed
+16
-3
No files matched your search
@@ -33,7 +33,7 @@ export async function findCandidates(options) {
|
||||
const matchesPerIssue = 200;
|
||||
const issueMap = new Map();
|
||||
let offset = 0;
|
||||
const truncatedIssues = [];
|
||||
const truncatedIssueMap = new Map();
|
||||
|
||||
while (true) {
|
||||
const query = new URLSearchParams({
|
||||
@@ -46,14 +46,17 @@ export async function findCandidates(options) {
|
||||
matchesPerIssue: String(matchesPerIssue),
|
||||
});
|
||||
const page = await getPaperclip(`/companies/${companyId}/search/extract?${query}`, { apiUrl, apiKey });
|
||||
for (const issue of page.results) issueMap.set(issue.issueId, issue);
|
||||
for (const issue of page.results) {
|
||||
if (issue.matchesTruncated) truncatedIssues.push({ issueId: issue.issueId, identifier: issue.identifier });
|
||||
issueMap.set(issue.issueId, issue);
|
||||
if (issue.matchesTruncated) {
|
||||
truncatedIssueMap.set(issue.issueId, { issueId: issue.issueId, identifier: issue.identifier });
|
||||
}
|
||||
}
|
||||
if (!page.hasMore) break;
|
||||
offset += limit;
|
||||
if (offset > 5000) throw new Error("Extract-search pagination exceeded the supported 5000 issue offset");
|
||||
}
|
||||
const truncatedIssues = [...truncatedIssueMap.values()];
|
||||
if (truncatedIssues.length > 0) {
|
||||
console.warn(`Warning: ${truncatedIssues.length} issue(s) had truncated match sets (>${matchesPerIssue} PR URL matches). These issues may contribute incomplete PR discovery: ${truncatedIssues.map((i) => i.identifier ?? i.issueId).join(", ")}. Proceeding with available data.`);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,16 @@ test("candidate discovery reports truncated issue matches without discarding the
|
||||
matchesTruncated: true,
|
||||
matches: [],
|
||||
},
|
||||
{
|
||||
issueId: "issue-truncated",
|
||||
identifier: "PAP-TRUNCATED",
|
||||
title: "Large PR thread",
|
||||
status: "done",
|
||||
assigneeAgentId: "agent-1",
|
||||
updatedAt: "2026-07-13T00:00:00Z",
|
||||
matchesTruncated: true,
|
||||
matches: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user