-
Notifications
You must be signed in to change notification settings - Fork 0
5k issues per day distribution #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joshua-quek-sonarsource
merged 1 commit into
main
from
fix/fix-98-migrate-more-than-10k-issues
Apr 23, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,3 +1,3 @@ | ||
| // -------- Batch Distributor Re-export -------- | ||
|
|
||
| export { shouldBatch, computeBatchPlan, computeBatchDate, createBatchExtractedData } from './batch-distributor/index.js'; | ||
| export { shouldBatch, computeBatchPlan, computeBatchDate, createBatchExtractedData, backdateChangesets } from './batch-distributor/index.js'; |
117 changes: 117 additions & 0 deletions
117
src/shared/utils/batch-distributor/helpers/backdate-changesets.js
This file contains hidden or 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,117 @@ | ||
| import logger from '../../logger.js'; | ||
| import { ISSUE_BATCH_SIZE } from './should-batch.js'; | ||
| import { computeBatchDate } from './compute-batch-date.js'; | ||
|
|
||
| // -------- Backdate Changesets -------- | ||
|
|
||
| const STUB_AUTHOR = 'cloudvoyager-migration@sonarcloud.io'; | ||
|
|
||
| /** | ||
| * Modify SCM changeset blame dates so the CE assigns different creation | ||
| * dates to different groups of issues. This spreads issues across | ||
| * multiple date buckets within a **single** analysis. | ||
| * | ||
| * Strategy: sort issues by file, group files into ≤5K-issue batches, | ||
| * then set ALL lines of each file to that batch's date. Setting every | ||
| * line ensures the CE has no "newer" line to fall back on. | ||
| * | ||
| * Mutates extractedData.issues (sort order) and | ||
| * extractedData.changesets (dates) in place. | ||
| */ | ||
| export function backdateChangesets(extractedData) { | ||
| const issues = extractedData.issues || []; | ||
| if (issues.length <= ISSUE_BATCH_SIZE) return; | ||
|
|
||
| const baseDateISO = extractedData.metadata?.extractedAt || new Date().toISOString(); | ||
|
|
||
| // Sort issues by component so files are contiguous | ||
| issues.sort((a, b) => (a.component || '').localeCompare(b.component || '')); | ||
|
|
||
| // Group files into batches of ≤ISSUE_BATCH_SIZE issues. | ||
| // Each file goes entirely into one batch (no splitting a file across batches). | ||
| const fileBatches = buildFileBatches(issues); | ||
| const batchCount = fileBatches.length; | ||
|
|
||
| if (batchCount <= 1) return; | ||
|
|
||
| logger.info( | ||
| `Backdating SCM data: ${issues.length} issues → ${batchCount} date buckets of ≤${ISSUE_BATCH_SIZE}` | ||
| ); | ||
|
|
||
| let modifiedFiles = 0; | ||
|
|
||
| for (let batchIdx = 0; batchIdx < batchCount; batchIdx++) { | ||
| if (batchIdx === batchCount - 1) break; // last batch keeps original date | ||
|
|
||
| const batchDateMs = new Date( | ||
| computeBatchDate(baseDateISO, batchIdx, batchCount) | ||
| ).getTime(); | ||
|
|
||
| const batchRevision = `cloudvoyager-batch-${String(batchIdx + 1).padStart(4, '0')}`; | ||
|
|
||
| for (const compKey of fileBatches[batchIdx].files) { | ||
| const cs = extractedData.changesets.get(compKey); | ||
| if (!cs) continue; | ||
|
|
||
| // Replace the single stub changeset with the backdated one | ||
| cs.changesets = [{ | ||
| revision: batchRevision, | ||
| author: STUB_AUTHOR, | ||
| date: batchDateMs, | ||
| }]; | ||
| // Point every line to changeset index 0 (the only entry) | ||
| cs.changesetIndexByLine.fill(0); | ||
|
|
||
| modifiedFiles++; | ||
| } | ||
| } | ||
|
|
||
| logger.info( | ||
| `Modified SCM data for ${modifiedFiles} files across ${batchCount} date buckets` | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Walk the sorted issues array and collect files into batches. | ||
| * Each batch accumulates files until the issue count exceeds | ||
| * ISSUE_BATCH_SIZE, then a new batch starts. | ||
| */ | ||
| function buildFileBatches(issues) { | ||
| const batches = [{ files: new Set(), issueCount: 0 }]; | ||
| let currentFile = null; | ||
| let currentFileIssueCount = 0; | ||
|
|
||
| for (const issue of issues) { | ||
| const compKey = issue.component; | ||
| if (!compKey) continue; | ||
|
|
||
| if (compKey !== currentFile) { | ||
| // New file — flush previous file's count and decide batch placement | ||
| if (currentFile && currentFileIssueCount > 0) { | ||
| let batch = batches[batches.length - 1]; | ||
| if (batch.issueCount + currentFileIssueCount > ISSUE_BATCH_SIZE && batch.issueCount > 0) { | ||
| batches.push({ files: new Set(), issueCount: 0 }); | ||
| batch = batches[batches.length - 1]; | ||
| } | ||
| batch.files.add(currentFile); | ||
| batch.issueCount += currentFileIssueCount; | ||
| } | ||
| currentFile = compKey; | ||
| currentFileIssueCount = 0; | ||
| } | ||
| currentFileIssueCount++; | ||
| } | ||
|
|
||
| // Flush last file | ||
| if (currentFile && currentFileIssueCount > 0) { | ||
| let batch = batches[batches.length - 1]; | ||
| if (batch.issueCount + currentFileIssueCount > ISSUE_BATCH_SIZE && batch.issueCount > 0) { | ||
| batches.push({ files: new Set(), issueCount: 0 }); | ||
| batch = batches[batches.length - 1]; | ||
| } | ||
| batch.files.add(currentFile); | ||
| batch.issueCount += currentFileIssueCount; | ||
| } | ||
|
|
||
| return batches; | ||
| } |
4 changes: 3 additions & 1 deletion
4
src/shared/utils/batch-distributor/helpers/compute-batch-date.js
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
backdateChangesetscall in sq-2025 transfer-branch pipelineHigh Severity
The
sq-2025/transfer-branch/index.jsentry point is the only one that was not updated to callbackdateChangesets. All other pipeline entry points (sq-10.0, sq-10.4, sq-9.9, and even sq-2025's owntransfer-pipelinevariant) correctly callbackdateChangesets(extractedData)in the non-batched path. This file still only importsshouldBatch(withoutbackdateChangesets) and never performs SCM date-bucket distribution, so large projects migrated through the sq-2025transfer-branchpath will hit the 10K Elasticsearch visualization cap. The changelog's claim that "All 6 pipelinetransfer-branchentry points" were updated is incorrect.Additional Locations (1)
docs/CHANGELOG.md#L35-L36Reviewed by Cursor Bugbot for commit a7a7116. Configure here.