From 75b8e837e39eee3513c0fd26a8e109d4cbe8b171 Mon Sep 17 00:00:00 2001 From: Jalisa Malik Date: Sat, 30 May 2026 21:50:10 +0530 Subject: [PATCH 1/2] test(calculate): add weekend-only commit streak edge case --- lib/calculate.test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/calculate.test.ts b/lib/calculate.test.ts index c3467c7d..4a03355d 100644 --- a/lib/calculate.test.ts +++ b/lib/calculate.test.ts @@ -270,6 +270,35 @@ describe('calculateStreak', () => { expect(result.longestStreak).toBe(10); expect(result.currentStreak).toBe(5); }); + + it('handles weekend-only commits correctly across massive 5-day gaps', () => { + // 2024-01-01 is a Monday. + // We simulate a user who commits ONLY on Saturdays and Sundays. + const calendar = buildCalendar([ + 0, + 0, + 0, + 0, + 0, + 1, + 1, // Week 1: Mon-Fri (0), Sat-Sun (1) + 0, + 0, + 0, + 0, + 0, + 1, + 1, // Week 2: Mon-Fri (0), Sat-Sun (1) + ]); + + const result = calculateStreak(calendar); + + // The gap from Monday to Friday is 5 days, which far exceeds the + // default grace period of 1. Therefore, the streak must break every week. + expect(result.currentStreak).toBe(2); + expect(result.longestStreak).toBe(2); + expect(result.totalContributions).toBe(4); + }); }); it('handles massive single-day commit spike timeline', () => { const calendar = buildCalendar([ From de69685b6876f935f4c765193e1db5dbb567cbeb Mon Sep 17 00:00:00 2001 From: Jalisa Malik Date: Sat, 30 May 2026 23:20:14 +0530 Subject: [PATCH 2/2] docs(readme): add documentation for grace period parameter --- README.md | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/README.md b/README.md index e38e5b5e..a9bdba42 100644 --- a/README.md +++ b/README.md @@ -174,35 +174,12 @@ URL Parameter > Theme Default > System Fallback | `hide_background` | `boolean` | No | `false` | Remove the background rect, letting the monolith float on the page | | `hide_stats` | `boolean` | No | `false` | Hides the bottom row displaying Current Streak, Annual Sync Total, and Peak Streak stats when set to `true` or `1`. | | `tz` | `string` | No | Omitted = UTC | IANA timezone (e.g. `Asia/Kolkata`, `America/New_York`) — aligns "today" with the user local midnight. Note: `?tz=UTC` is valid but cached separately from omitting `tz`. | +| `grace` | `number` | No | `1` | Configures the streak survival grace period in days (0 to 7). Useful for weekend-only contributors. | | `lang` | `string` | No | `en` | Language code for labels (`en`, `es`, `hi`, `fr`, `pt`, `ko`, `ja`, `de`, `zh`) | | `view` | `string` | No | `default` | Rendering mode: `default` (3D Monolith) or `monthly` (Compact monthly stats) | | `delta_format` | `string` | No | `percent` | Format for month-over-month delta in monthly view: `percent` (e.g. +12%), `absolute` (e.g. +15 commits), or `both` | | `width` | `number` | No | `300` | Custom width for the SVG canvas (currently only applies to `view=monthly`) | | `height` | `number` | No | `120` | Custom height for the SVG canvas (currently only applies to `view=monthly`) | -| Parameter | Type | Required | Default | Description | -| ----------------- | --------- | ---------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | -| `user` | `string` | ✅ **Yes** | — | GitHub username to render | -| `theme` | `string` | No | `dark` | Preset theme name (see below) | -| `bg` | `hex` | No | Theme default | Background color — **without** `#` | -| `accent` | `hex` | No | Theme default | Tower & glow color — **without** `#` | -| `text` | `hex` | No | Theme default | Label & stat text color — **without** `#` | -| `radius` | `number` | No | `8` | Border corner radius in pixels | -| `border` | `string` | No | — | Custom stroke color around the main SVG container — **without** `#` | -| `speed` | `string` | No | `8s` | Radar scan duration (`2s`–`20s`, default `8s`) | -| `scale` | `string` | No | `linear` | Tower height scaling: `linear` or `log` (logarithmic) | -| `size` | `string` | No | `medium` | Badge dimensions: `small` (400×280), `medium` (600×420), `large` (800×560) | -| `font` | `string` | No | CommitPulse default typography | Any **Google Font** name (e.g. `Orbitron`, `Inter`) | -| `refresh` | `boolean` | No | `false` | Bypass cache for real-time data | -| `year` | `string` | No | — | Calendar year to render (e.g. `2023`, `2024`) | -| `hide_title` | `boolean` | No | `false` | Hide GitHub username/title from the SVG badge | -| `hide_background` | `boolean` | No | `false` | Remove the background rect, letting the monolith float on the page | -| `hide_stats` | `boolean` | No | `false` | Hides the bottom row displaying Current Streak, Annual Sync Total, and Peak Streak stats when set to `true` or `1`. | -| `tz` | `string` | No | Omitted = UTC | IANA timezone (e.g. `Asia/Kolkata`) — aligns "today" with the user local midnight. Note: `?tz=UTC` is cached separately from omitting `tz`. | -| `lang` | `string` | No | `en` | Language code for labels (`en`, `es`, `hi`, `fr`, `pt`, `ko`, `ja`) | -| `view` | `string` | No | `default` | Rendering mode: `default` (3D Monolith) or `monthly` (Compact monthly stats) | -| `delta_format` | `string` | No | `percent` | Format for month-over-month delta in monthly view: `percent` (e.g. +12%), `absolute` (e.g. +15 commits), or `both` | -| `width` | `number` | No | `300` | Custom width for the SVG canvas (currently only applies to `view=monthly`) | -| `height` | `number` | No | `120` | Custom height for the SVG canvas (currently only applies to `view=monthly`) | ### Theme Presets