AnkeshThakur opened a new pull request, #8714: URL: https://github.com/apache/incubator-devlake/pull/8714
## Summary This PR optimizes the change lead time calculation in the DORA plugin by eliminating the N+1 query problem through batch fetching. ## Changes ### Performance Optimization - Implemented `batchFetchFirstCommits()` - fetches all first commits in a single query - Implemented `batchFetchFirstReviews()` - fetches all first reviews in a single query - Implemented `batchFetchDeployments()` - fetches all deployments in a single query - Modified `CalculateChangeLeadTime()` to call batch functions upfront and use O(1) map lookups ### Bug Fix - Fixed NULL `author_id` handling in review queries to properly process PRs with empty author_id field ## Performance Impact **Before optimization:** - 3 database queries per PR - For 10,000 PRs: 30,001 queries **After optimization:** - 3 batch queries total regardless of PR count - For 10,000 PRs: 3 queries (99.99% reduction) ## Testing - ✅ All existing unit tests pass - ✅ All E2E tests pass including edge cases with NULL author_id - ✅ Batch fetch operations complete in ~5-6ms for test dataset - ✅ Data integrity verified - results match previous implementation ## Related Issue This addresses performance issues with change lead time calculation for repositories with large numbers of pull requests, where the previous implementation caused significant database load and slow calculation times. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
