Added new feature to calculate Advance Analysis with PAT only for mor…#109
Added new feature to calculate Advance Analysis with PAT only for mor…#109rahul-vyas-dev wants to merge 1 commit into
Conversation
WalkthroughAdds a ChangesAdvanced Analytics Feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant AnalyticsPage
participant AppContext
participant GitHubService
User->>AnalyticsPage: Select repo / click "Collect Advanced Metrics"
AnalyticsPage->>AppContext: runAdvanceAnalytics()
AppContext->>AppContext: batch totalRepos in groups of 5
loop each repo
AppContext->>GitHubService: fetchPulls(org, repo, pat)
GitHubService-->>AppContext: pull request pages
end
AppContext-->>AnalyticsPage: pullsData, advanceAnalyticsLoading=false
AnalyticsPage->>AnalyticsPage: useAdvancedMetrics(filteredPulls)
AnalyticsPage-->>User: Render merge-time & acceptance charts
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/context/AppContext.jsx`:
- Around line 156-172: `runAdvanceAnalytics` is iterating every repo in
`model.totalRepos`, which can burn through the shared GitHub rate limit for
unauthenticated users. Mirror the scope guard used in `runAudit` by limiting the
repo list (for example, take only the first 15 repos when no PAT is present)
before the batching loop in `runAdvanceAnalytics`, while still preserving the
existing 5-at-a-time `Promise.allSettled` behavior and `fetchPulls` usage.
In `@src/pages/AnalyticsPage.jsx`:
- Around line 300-316: The metric-card icons in AnalyticsPage still use
hardcoded green/purple values instead of the theme CSS variable convention.
Update the clock and purple icon blocks in the metric-card rendering logic to
derive both the background tint and icon color from the matching theme variables
used elsewhere (for example, the same pattern as the chart series colors), so
they stay consistent with theme changes. Use the existing icon/card markup near
the HiOutlineClock and the purple icon section to make the replacement without
changing the layout.
- Around line 271-279: The button in AnalyticsPage’s advanced analytics control
is missing an explicit type and currently relies on the default submit behavior.
Update the button rendered near runAdvanceAnalytics()/advanceAnalyticsLoading to
include type="button" so it won’t accidentally submit a surrounding form if
placed inside one.
- Around line 46-54: Move the `useAdvancedMetrics` hook call in `AnalyticsPage`
so it runs before any conditional early return, ensuring the hooks order is
identical on every render. Keep the `filteredPulls` `useMemo` and
`useAdvancedMetrics(filteredPulls)` invocation together near the top of the
component, then apply the `if (!model) return null` guard afterward to avoid the
hooks mismatch when `model` changes from null to populated.
- Around line 494-505: The Pie chart in AnalyticsPage is using blendStroke with
a color value, but blendStroke is only a boolean flag and won’t create the
intended divider color. Update the Pie component in AnalyticsPage to use the
stroke prop for the surface-colored separator, keeping the existing
acceptanceChart, Cell, and label setup unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1275c39c-24df-4aea-8614-f9de90ba8045
📒 Files selected for processing (4)
src/context/AppContext.jsxsrc/hooks/useSortedData.jssrc/pages/AnalyticsPage.jsxsrc/services/github.js
Screenshots/Recordings:
Before: -

After: -

https://1drv.ms/v/c/2b55451e453f4443/IQD-HejpVnhhRa28xYOEfy9xAdlzQh1IUjrgI1pscMAm960?e=m87rQ0
Additional Notes:
Adds an Advanced Metrics section to the Analytics dashboard, providing key repository and pull request insights.
What's added: -
This enhances the Analytics page by surfacing actionable development KPIs alongside existing activity trends.
This are calculated based on the PRs within an org of all the repos and by using mathematical formula all the insights are generated.
Mathematical formulas are: -
const avgMergeDays = mergedPRs.length === 0 ? 0 : totalMergeTime / mergedPRs.length / (1000 * 60 * 60 * 24)const acceptanceRate = mergedPRs.length + rejectedPRs.length === 0 ? 0 : (mergedPRs.length / (mergedPRs.length + rejectedPRs.length)) * 100Checklist
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.