Skip to content

Added new feature to calculate Advance Analysis with PAT only for mor…#109

Open
rahul-vyas-dev wants to merge 1 commit into
AOSSIE-Org:mainfrom
rahul-vyas-dev:feat/PR-advance-analysis
Open

Added new feature to calculate Advance Analysis with PAT only for mor…#109
rahul-vyas-dev wants to merge 1 commit into
AOSSIE-Org:mainfrom
rahul-vyas-dev:feat/PR-advance-analysis

Conversation

@rahul-vyas-dev

@rahul-vyas-dev rahul-vyas-dev commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Screenshots/Recordings:

Before: -
image

After: -
Screenshot_4-7-2026_234754_localhost

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: -

  • Added Average PR Merge Time metric with a visual gauge.
  • Added Pull Request Acceptance Rate metric with acceptance vs. rejection visualization.
  • Added Repository Growth Rate metric with growth trend chart.
  • Added repository selector to view metrics for a specific repository or across all repositories.
  • Extracted advanced metric calculations into a reusable hook for improved maintainability.
  • Improved card layout, icons, and overall dashboard UI consistency.

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)) * 100

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

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.

@github-actions github-actions Bot added no-issue-linked PR has no linked issue frontend Frontend changes javascript JavaScript/TypeScript changes size/L 201-500 lines changed external-contributor External contributor labels Jul 4, 2026
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a fetchPulls GitHub service function for paginated pull-request retrieval, a runAdvanceAnalytics context action that batches per-repo fetches into pullsData, a useAdvancedMetrics hook computing merge/acceptance metrics, and a new Advanced Analytics UI section in AnalyticsPage with theme-based chart color updates.

Changes

Advanced Analytics Feature

Layer / File(s) Summary
Pull request fetch service
src/services/github.js
Adds fetchPulls(org, repo, pat) that paginates the GitHub pulls endpoint (state=all, per_page=100) via fetchWithCache and concatenates results.
Batched fetch orchestration and context state
src/context/AppContext.jsx
Adds pullsData/advanceAnalyticsLoading state and runAdvanceAnalytics, which batches repos in groups of 5, calls fetchPulls per repo, and exposes the new state/action via the context provider.
Aggregate metrics hook
src/hooks/useSortedData.js
Adds useAdvancedMetrics(pulls) that memoizes merged/rejected counts, average merge duration, and acceptance rate.
Advanced Analytics UI section
src/pages/AnalyticsPage.jsx
Consumes new context fields and useAdvancedMetrics, adds repo selection and derived chart data (acceptanceChart, mergeGauge, getMergeColor), renders a repo dropdown, a "Collect Advanced Metrics" trigger, radial merge-time and acceptance-rate pie charts, and updates existing area chart colors to theme CSS variables.

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
Loading

Possibly related PRs

  • AOSSIE-Org/OrgExplorer#63: Introduced the base AppContext, AnalyticsPage, and src/services/github.js modules that this PR extends with fetchPulls and Advanced Analytics wiring.
  • AOSSIE-Org/OrgExplorer#94: Adds model.totalRepos, which runAdvanceAnalytics iterates over to fetch per-repo pull requests.

Suggested labels: Typescript Lang

Suggested reviewers: bhavik-mangla, Zahnentferner

Poem

A rabbit hops through pages of PRs,
Merged and rejected, tallied with ease,
🥕 Gauges spin and pie charts gleam,
Advanced Analytics — a data dream!
Thump thump goes my joyful heart! 🐇✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title refers to the new advanced analysis feature and PAT-based pull request data work, which matches the main change set.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size/L 201-500 lines changed and removed size/L 201-500 lines changed labels Jul 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d904719 and 2b02d49.

📒 Files selected for processing (4)
  • src/context/AppContext.jsx
  • src/hooks/useSortedData.js
  • src/pages/AnalyticsPage.jsx
  • src/services/github.js

Comment thread src/context/AppContext.jsx
Comment thread src/pages/AnalyticsPage.jsx
Comment thread src/pages/AnalyticsPage.jsx
Comment thread src/pages/AnalyticsPage.jsx
Comment thread src/pages/AnalyticsPage.jsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor External contributor frontend Frontend changes javascript JavaScript/TypeScript changes no-issue-linked PR has no linked issue size/L 201-500 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant