Skip to content

fix(radar): replace fake nightOwl/diversity with real calendar data#6250

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
vivek0369:fix/radar-real-nightowl-diversity-metrics
Jun 21, 2026
Merged

fix(radar): replace fake nightOwl/diversity with real calendar data#6250
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
vivek0369:fix/radar-real-nightowl-diversity-metrics

Conversation

@vivek0369

Copy link
Copy Markdown
Contributor

fix(radar): replace fabricated nightOwl & diversity metrics with real contribution analytics

Description

Closes #5995

This PR removes two placeholder metrics from the Radar visualization and replaces them with values derived from real contribution data.

Previously, the nightOwl and diversity axes were generated using deterministic random values. While these values were stable between renders, they did not represent actual user behavior, resulting in a Radar chart where 2 of the 6 displayed metrics were synthetic rather than data-driven.

This change ensures that every Radar metric is calculated from real contribution information already available in the existing ContributionCalendar payload, with no additional API requests required.


Why This Change?

The Radar chart is intended to provide meaningful insights into a user's contribution patterns. However, the current implementation relies on deterministic random values for two metrics:

// Night Owl: Since we don't have hour-level data, we use deterministic random
const nightOwl = 0.2 + 0.6 * deterministicRandom(`${seed}:nightowl`);

// Diversity: deterministic random as placeholder
const diversity = 0.3 + 0.7 * deterministicRandom(${seed}:diversity);

This creates a data integrity issue because:

  • 33% of the Radar chart is based on fabricated values.

  • Metrics can change without any corresponding change in user behavior.

  • Users may assume all Radar insights are backed by actual GitHub data.

  • The visualization becomes less trustworthy as an analytics tool.


What Changed?

Replace nightOwl with a real behavioral proxy

The new implementation derives a score from actual weekday contribution patterns:

const nightOwl =
weekdayCommits > 0
? Math.min(1, weeknightCommits / weekdayCommits)
: 0;

Implementation details:

  • Iterates through existing contribution calendar data.

  • Counts contributions made Monday–Thursday (weeknightCommits).

  • Compares them against total weekday contributions (weekdayCommits).

  • Produces a normalized value between 0 and 1.

Benefits:

  • Uses real contribution activity.

  • Requires no new data sources.

  • Provides a meaningful proxy for consistent weekday coding behavior.


Replace diversity with repository contribution diversity

The new metric uses repository participation data already available in the calendar payload:

const diversity =
typeof calendar.repoContributions === "number" &&
calendar.repoContributions > 0
? Math.min(1, calendar.repoContributions / 20)
: 0.3;

Implementation details:

  • Uses the existing repoContributions field.

  • Measures repository participation breadth.

  • Normalizes the value using 20 repositories as the upper threshold.

Benefits:

  • Reflects actual contribution diversity.

  • Rewards activity across multiple repositories.

  • Eliminates synthetic scoring.

  • Requires no API or schema changes.


Additional Cleanup

As part of this refactor:

  • Removed the unused deterministicRandom import.

  • Removed the obsolete seed variable.

  • Removed the associated CodeQL suppression comment.

  • Simplified Radar metric calculation logic.

Function Signature

Before:

calculateRadarMetrics(calendar, seed)

After:

calculateRadarMetrics(calendar)

Since Radar metrics are now fully data-driven, the seed parameter is no longer necessary.


Files Modified

File Description
lib/svg/radar.ts Replaced placeholder metrics with real analytics and removed obsolete randomization logic

Testing

Night Owl Metric

  • Heavy Monday–Thursday contributors produce higher scores.

  • Primarily weekend contributors produce lower scores.

  • Users with no weekday contributions receive a score of 0.

Diversity Metric

  • repoContributions = 100.5

  • repoContributions >= 201.0

  • Missing value → fallback 0.3

Verification

  • No API changes.

  • No GraphQL changes.

  • No breaking interface changes.

  • Existing Radar rendering continues to work as expected.

  • All Radar axes are now backed by real contribution data.


Impact

This PR improves the accuracy, transparency, and reliability of CommitPulse analytics by ensuring that every Radar metric represents actual contribution behavior rather than deterministic placeholder values.

Type of Change

  • Bug fix (non-breaking change)

  • Code quality improvement

  • Data integrity enhancement

  • Analytics accuracy improvement

@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

@vivek0369 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 3697.00 KB 3697.00 KB 0 B
Total CSS 296.58 KB 296.58 KB 0 B

@Aamod-Dev Aamod-Dev added GSSoC 2026 mentor:Aamod007 level:advanced Complex contributions involving architecture, optimization, or significant feature work quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. refactor feature A completely new feature or major addition to the project. labels Jun 21, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Replacing the synthetic deterministicRandom values for nightOwl and diversity with actual data-driven metrics in lib/svg/radar.ts makes the Radar visualization significantly more valuable and trustworthy. Removing the obsolete seed parameter is also a great cleanup step. Approved!

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 21, 2026
@JhaSourav07 JhaSourav07 merged commit 947dbe9 into JhaSourav07:main Jun 21, 2026
11 of 12 checks passed
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @vivek0369! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@vivek0369

vivek0369 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Aamod-Dev and @JhaSourav07 , add label Type bonuses
Type labels add flat bonus points on top of the difficulty score. Multiple types are cumulative. Only apply them when the primary purpose of the PR matches, not as a secondary label for something the PR briefly touches.

type:bug
+10
Fixes incorrect behavior that was already reported or demonstrably wrong.

type:feature
+10
Adds new functionality not previously present.

type:docs
+5
Improves or adds documentation, README, or inline comments.

type:testing
+10
Adds or improves tests: unit, integration, or e2e.

type:refactor
+10
Restructures existing code without changing behavior.

type:design
+10
Visual or UI/UX improvements.

type:accessibility
+15
Improves screen reader support, keyboard nav, contrast, or ARIA.

type:performance
+15
Measurably reduces load time, bundle size, or memory usage.

type:devops
+15
CI/CD, Dockerfile, GitHub Actions, or deployment configuration.

type:security
+20
Addresses a security vulnerability or hardens a surface area.

@github-actions github-actions Bot added the type:bug Something isn't working as expected label Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A completely new feature or major addition to the project. gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:advanced Complex contributions involving architecture, optimization, or significant feature work mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. refactor type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Radar Data Integrity: Replace Placeholder nightOwl and diversity Metrics with Real Analytics

3 participants