Skip to content

Commit 00c7205

Browse files
committed
refactor: optimize imports and improve URL synchronization in HomePageClient
1 parent e9cfbf3 commit 00c7205

4 files changed

Lines changed: 9 additions & 55 deletions

File tree

components/home-page-client.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,13 @@ export function HomePageClient() {
343343
useEffect(() => {
344344
const params = searchParams.getAll("username");
345345
const urlLanguages = sanitizeSelectedLanguages(searchParams.getAll("selectedLanguage"));
346-
syncToUrl(
347-
params[0] ?? "",
348-
params[1] ?? "",
349-
urlLanguages,
350-
);
346+
queueMicrotask(() => {
347+
syncToUrl(
348+
params[0] ?? "",
349+
params[1] ?? "",
350+
urlLanguages,
351+
);
352+
});
351353
}, [searchParams]);
352354

353355
useEffect(() => {
@@ -357,7 +359,6 @@ export function HomePageClient() {
357359
}
358360

359361
if (data) {
360-
setDisplayData(data);
361362
return;
362363
}
363364

lib/calculate-leaderboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import yaml from "js-yaml";
2-
import { createGitHubUserDataFetcherWithMetrics, getUserData } from "@/lib/github";
2+
import { getUserData } from "@/lib/github";
33
import { calculateUserScore } from "@/lib/score";
44
import { createCacheStore, getCacheConfigFromEnv } from "@/lib/cache-store";
55
import { getDatabaseStore, type DatabaseStore } from "@/lib/db-store";

lib/github.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
DEFAULT_GITHUB_CACHE_TTL_SECONDS,
32
createCacheStore,
43
getCacheConfigFromEnv,
54
type CacheConfig,
@@ -61,35 +60,6 @@ type PageInfo = {
6160
endCursor: string | null;
6261
};
6362

64-
type FetchUserAndPullRequestsResponse = {
65-
user: GitHubRawUser | null;
66-
pullRequests: {
67-
nodes: Array<PullRequestNode | null>;
68-
pageInfo: PageInfo;
69-
};
70-
};
71-
72-
type FetchPullRequestsPageResponse = {
73-
pullRequests: {
74-
nodes: Array<PullRequestNode | null>;
75-
pageInfo: PageInfo;
76-
};
77-
};
78-
79-
type FetchIssuesPageResponse = {
80-
issues: {
81-
nodes: Array<RawIssueNode | null>;
82-
pageInfo: PageInfo;
83-
};
84-
};
85-
86-
type FetchDiscussionsPageResponse = {
87-
discussions: {
88-
nodes: Array<RawDiscussionNode | null>;
89-
pageInfo: PageInfo;
90-
};
91-
};
92-
9363
type GitHubQueryExecutor = Pick<GitHubGraphQLClient, "execute">;
9464

9565
export type GitHubFetcherDependencies = {
@@ -341,15 +311,6 @@ function isObject(value: unknown): value is Record<string, unknown> {
341311
return typeof value === "object" && value !== null;
342312
}
343313

344-
function isNumericRecord(value: unknown): value is Record<string, number> {
345-
return (
346-
isObject(value) &&
347-
Object.values(value).every(
348-
(item) => typeof item === "number" && Number.isFinite(item),
349-
)
350-
);
351-
}
352-
353314
function isGitHubUserData(value: unknown): value is GitHubUserData {
354315
if (!isObject(value)) {
355316
return false;
@@ -759,14 +720,6 @@ function getStaleDays(): number {
759720
return Number.isFinite(parsed) && parsed > 0 ? parsed : 14;
760721
}
761722

762-
/**
763-
* Fetch fresh user data from the GitHub API.
764-
*/
765-
async function fetchFromGitHubApi(username: string): Promise<GitHubUserData> {
766-
const { data } = await fetchUserDataFromGitHub(executorSingleton, username);
767-
return data;
768-
}
769-
770723
/**
771724
* Unified function to get GitHub user data.
772725
*

scripts/calculate-next-country.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import "dotenv/config";
2121

2222
import { getDatabaseStore } from "@/lib/db-store";
23-
import { calculateLeaderboard, type LeaderboardResult } from "@/lib/calculate-leaderboard";
23+
import { calculateLeaderboard } from "@/lib/calculate-leaderboard";
2424
import { logger } from "@/lib/logger";
2525

2626
async function main() {

0 commit comments

Comments
 (0)