Skip to content

Commit 581a63d

Browse files
authored
refactor(github): move achievement milestones to config file (JhaSourav07#556)
## Description Fixes JhaSourav07#312 ## Pillar - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview *No visual changes (Pure architectural code refactoring).* ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `refactor(github): ...`). - [x] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have starred the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 29a052c + c8e8f69 commit 581a63d

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

lib/github.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { ContributionCalendar, ContributionDay } from '@/types';
44
import { calculateStreak, aggregateCalendars, calculateWrappedStats } from '@/lib/calculate';
55
import { TTLCache } from '@/lib/cache';
66
import { LANGUAGE_COLORS } from '@/lib/svg/languageColors';
7+
import { CONTRIBUTION_MILESTONES, STREAK_MILESTONES } from './svg/constants';
78

89
interface GitHubRepo {
910
stargazers_count: number;
@@ -12,10 +13,8 @@ interface GitHubRepo {
1213

1314
const MAX_RETRIES = 3;
1415
const BASE_DELAY_MS = 500;
15-
const CONTRIBUTION_MILESTONES = [1, 10, 100, 250, 500, 1000];
16-
const STREAK_MILESTONES = [3, 7, 30, 100];
17-
const GRAPHQL_TIMEOUT_MS = 8000;
18-
const REST_TIMEOUT_MS = 5000;
16+
const GRAPHQL_TIMEOUT_MS = 8000; // 8s for GraphQL endpoint
17+
const REST_TIMEOUT_MS = 5000; // 5s for REST endpoints
1918

2019
export async function fetchWithRetry(
2120
url: string | URL,

lib/svg/constants.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const SVG_WIDTH = 600;
2+
export const SVG_HEIGHT = 420;
3+
4+
export const GHOST_HEIGHT_PX = 4;
5+
export const LOG_SCALE_MULTIPLIER = 12;
6+
export const LINEAR_SCALE_MULTIPLIER = 5;
7+
export const MAX_LOG_HEIGHT = 80;
8+
export const MAX_LINEAR_HEIGHT = 50;
9+
10+
export const FONT_MAP: Record<string, string> = {
11+
jetbrains: '"JetBrains Mono", monospace',
12+
fira: '"Fira Code", monospace',
13+
roboto: '"Roboto", sans-serif',
14+
};
15+
16+
export const CONTRIBUTION_MILESTONES = [1, 10, 100, 250, 500, 1000];
17+
export const STREAK_MILESTONES = [3, 7, 30, 100];

0 commit comments

Comments
 (0)