-
-
Notifications
You must be signed in to change notification settings - Fork 87
feat: Add Contributor Expertise & Insights to Contributor Profile (#199) #207
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
Open
zaibamachhaliya
wants to merge
1
commit into
AOSSIE-Org:main
Choose a base branch
from
zaibamachhaliya:feat/contributor-expertise-insights
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,315 @@ | ||
| import React, { useMemo } from 'react'; | ||
| import { | ||
| analyzeExpertise, | ||
| generateInsights, | ||
| hasSufficientData, | ||
| getContributionSummary | ||
| } from '../utils/contributorExpertise'; | ||
| import { FiInfo, FiAlertCircle } from 'react-icons/fi'; | ||
|
|
||
| const ExpertiseLevelBadge = ({ level }) => { | ||
| const styles = { | ||
| HIGH: { | ||
| background: 'rgba(34, 197, 94, 0.12)', | ||
| color: '#22c55e', | ||
| border: '1px solid rgba(34, 197, 94, 0.2)' | ||
| }, | ||
| MEDIUM: { | ||
| background: 'rgba(251, 191, 36, 0.12)', | ||
| color: '#d97706', | ||
| border: '1px solid rgba(251, 191, 36, 0.2)' | ||
| }, | ||
| LOW: { | ||
| background: 'rgba(107, 114, 128, 0.12)', | ||
| color: '#6b7280', | ||
| border: '1px solid rgba(107, 114, 128, 0.15)' | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <span style={{ | ||
| padding: '2px 10px', | ||
| borderRadius: 12, | ||
| fontSize: 10, | ||
| fontWeight: 700, | ||
| letterSpacing: '0.03em', | ||
| textTransform: 'uppercase', | ||
| ...styles[level] | ||
| }}> | ||
| {level} | ||
| </span> | ||
| ); | ||
| }; | ||
|
|
||
| const ExpertiseBar = ({ score, maxScore }) => { | ||
| const percentage = Math.min(100, (score / maxScore) * 100); | ||
| return ( | ||
| <div style={{ | ||
| width: 60, | ||
| height: 3, | ||
| background: 'var(--border)', | ||
| borderRadius: 2, | ||
| overflow: 'hidden' | ||
| }}> | ||
| <div style={{ | ||
| width: `${percentage}%`, | ||
| height: '100%', | ||
| background: 'var(--accent)', | ||
| borderRadius: 2, | ||
| transition: 'width 0.3s ease' | ||
| }} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const ContributorExpertiseInsights = ({ contributions }) => { | ||
| const { expertise, insights, hasData, summary } = useMemo(() => { | ||
| if (!contributions || contributions.length === 0) { | ||
| return { | ||
| expertise: [], | ||
| insights: ['No contribution data available for analysis.'], | ||
| hasData: false, | ||
| summary: { total: 0, prs: 0, issues: 0, repos: [] } | ||
| }; | ||
| } | ||
|
|
||
| const expertiseData = analyzeExpertise(contributions); | ||
| const insightsData = generateInsights(contributions, expertiseData); | ||
| const summaryData = getContributionSummary(contributions); | ||
| const sufficient = hasSufficientData(contributions, 3); | ||
|
|
||
| return { | ||
| expertise: expertiseData, | ||
| insights: sufficient ? insightsData : ['Insufficient data to generate reliable insights. Need at least 3 contributions.'], | ||
| hasData: sufficient, | ||
| summary: summaryData | ||
| }; | ||
| }, [contributions]); | ||
|
|
||
| if (!contributions || contributions.length === 0) { | ||
| return ( | ||
| <div style={{ | ||
| background: 'var(--surface)', | ||
| borderRadius: 12, | ||
| border: '1px solid var(--border)', | ||
| padding: '40px 24px', | ||
| textAlign: 'center', | ||
| marginTop: 16, | ||
| marginBottom: 16 | ||
| }}> | ||
| <FiAlertCircle size={32} style={{ color: 'var(--text2)', marginBottom: 12 }} /> | ||
| <p style={{ color: 'var(--text2)', fontSize: 14, fontWeight: 500 }}> | ||
| No Contributions Found | ||
| </p> | ||
| <p style={{ color: 'var(--text3)', fontSize: 12, marginTop: 4 }}> | ||
| Contributions will appear here once the contributor makes PRs or issues. | ||
| </p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div style={{ | ||
| background: 'var(--surface)', | ||
| borderRadius: 12, | ||
| border: '1px solid var(--border)', | ||
| overflow: 'hidden', | ||
| marginTop: 16, | ||
| marginBottom: 16 | ||
| }}> | ||
| <div style={{ | ||
| display: 'flex', | ||
| justifyContent: 'space-between', | ||
| alignItems: 'center', | ||
| padding: '14px 20px', | ||
| borderBottom: '1px solid var(--border)', | ||
| background: 'var(--bg)' | ||
| }}> | ||
| <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}> | ||
| <span style={{ fontSize: 18 }}>🧠</span> | ||
| <h3 style={{ | ||
| fontSize: 15, | ||
| fontWeight: 600, | ||
| color: 'var(--text)', | ||
| margin: 0 | ||
| }}> | ||
| Contributor Expertise & Insights | ||
| </h3> | ||
| {summary.total > 0 && ( | ||
| <span style={{ | ||
| fontSize: 11, | ||
| padding: '2px 10px', | ||
| borderRadius: 12, | ||
| background: 'var(--border)', | ||
| color: 'var(--text2)', | ||
| fontWeight: 500 | ||
| }}> | ||
| {summary.total} contributions • {summary.uniqueRepos} repos | ||
| </span> | ||
| )} | ||
| </div> | ||
| </div> | ||
|
|
||
| <div style={{ | ||
| padding: '20px', | ||
| display: 'grid', | ||
| gridTemplateColumns: '1fr 1fr', | ||
| gap: 24 | ||
| }}> | ||
| <div> | ||
| <h4 style={{ | ||
| fontSize: 13, | ||
| fontWeight: 600, | ||
| color: 'var(--text2)', | ||
| marginBottom: 12, | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| gap: 8, | ||
| letterSpacing: '0.02em' | ||
| }}> | ||
| <span style={{ fontSize: 16 }}>🎯</span> Areas of Expertise | ||
| </h4> | ||
|
|
||
| {!hasData ? ( | ||
| <div style={{ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| padding: '12px 16px', | ||
| background: 'var(--bg)', | ||
| borderRadius: 6, | ||
| color: 'var(--text2)', | ||
| fontSize: 13, | ||
| border: '1px dashed var(--border)' | ||
| }}> | ||
| <FiInfo size={16} style={{ marginRight: 8, flexShrink: 0 }} /> | ||
| <span>Not enough data to determine expertise. More contributions needed.</span> | ||
| </div> | ||
| ) : expertise.length === 0 ? ( | ||
| <div style={{ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| padding: '12px 16px', | ||
| background: 'var(--bg)', | ||
| borderRadius: 6, | ||
| color: 'var(--text2)', | ||
| fontSize: 13, | ||
| border: '1px dashed var(--border)' | ||
| }}> | ||
| <FiInfo size={16} style={{ marginRight: 8, flexShrink: 0 }} /> | ||
| <span>No clear expertise identified from available contributions.</span> | ||
| </div> | ||
| ) : ( | ||
| <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}> | ||
| {expertise.map((item, index) => { | ||
| const maxScore = expertise[0]?.score || 1; | ||
| return ( | ||
| <div key={index} style={{ | ||
| display: 'flex', | ||
| justifyContent: 'space-between', | ||
| alignItems: 'center', | ||
| padding: '6px 0', | ||
| borderBottom: '1px solid var(--border)', | ||
| borderBottomWidth: '1px', | ||
| borderBottomStyle: 'solid', | ||
| borderBottomColor: 'var(--border)' | ||
| }}> | ||
| <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}> | ||
| <span style={{ fontSize: 16 }}>{item.icon}</span> | ||
| <span style={{ | ||
| fontSize: 13, | ||
| color: 'var(--text)', | ||
| fontWeight: 500 | ||
| }}> | ||
| {item.area} | ||
| </span> | ||
| </div> | ||
| <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}> | ||
| <ExpertiseBar score={item.score} maxScore={maxScore} /> | ||
| <ExpertiseLevelBadge level={item.level} /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| })} | ||
| </div> | ||
| )} | ||
| </div> | ||
|
|
||
| <div> | ||
| <h4 style={{ | ||
| fontSize: 13, | ||
| fontWeight: 600, | ||
| color: 'var(--text2)', | ||
| marginBottom: 12, | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| gap: 8, | ||
| letterSpacing: '0.02em' | ||
| }}> | ||
| <span style={{ fontSize: 16 }}>💡</span> Contribution Insights | ||
| </h4> | ||
|
|
||
| {insights.length === 0 || (insights.length === 1 && insights[0].includes('No contribution')) ? ( | ||
| <div style={{ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| padding: '12px 16px', | ||
| background: 'var(--bg)', | ||
| borderRadius: 6, | ||
| color: 'var(--text2)', | ||
| fontSize: 13, | ||
| border: '1px dashed var(--border)' | ||
| }}> | ||
| <FiInfo size={16} style={{ marginRight: 8, flexShrink: 0 }} /> | ||
| <span>{insights[0] || 'No insights available.'}</span> | ||
| </div> | ||
| ) : ( | ||
| <ul style={{ | ||
| listStyle: 'none', | ||
| padding: 0, | ||
| margin: 0 | ||
| }}> | ||
| {insights.map((insight, index) => ( | ||
| <li key={index} style={{ | ||
| display: 'flex', | ||
| alignItems: 'flex-start', | ||
| gap: 8, | ||
| padding: '6px 0', | ||
| fontSize: 13, | ||
| color: 'var(--text)', | ||
| lineHeight: 1.5, | ||
| borderBottom: '1px solid var(--border)', | ||
| borderBottomWidth: '1px', | ||
| borderBottomStyle: 'solid', | ||
| borderBottomColor: 'var(--border)' | ||
| }}> | ||
| <span style={{ | ||
| color: 'var(--accent)', | ||
| fontWeight: 700, | ||
| flexShrink: 0, | ||
| fontSize: 16 | ||
| }}>•</span> | ||
| <span>{insight}</span> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| )} | ||
| </div> | ||
| </div> | ||
|
|
||
| <div style={{ | ||
| padding: '8px 20px', | ||
| borderTop: '1px solid var(--border)', | ||
| background: 'var(--bg)' | ||
| }}> | ||
| <span style={{ | ||
| fontSize: 11, | ||
| color: 'var(--text3)' | ||
| }}> | ||
| Based on {summary.total} contribution{summary.total > 1 ? 's' : ''} from the selected period | ||
| </span> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ContributorExpertiseInsights; | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Make the insights grid responsive.
The fixed two-column grid remains two columns on narrow screens. This makes both cards too narrow or causes horizontal overflow. Use an auto-fit
minmaxgrid or a responsive class that switches to one column.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents