Skip to content

Commit

Permalink
refactor: apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HC-kang committed Nov 5, 2024
1 parent 1f3f11c commit d814bca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/api/config/type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Grade } from "../type";
import type { Grade } from "../type";

export type StudyConfig = {
organization: string;
Expand Down
2 changes: 2 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { fetchLeaderBoard } from "./services/store/storeService";
export type { MemberInfo } from "./services/common/types";
17 changes: 3 additions & 14 deletions src/api/services/fetch/fetchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,16 @@ export function createFetchService(config: Config) {
);

return submissions
.filter(isRelevantTree)
.filter((tree) => tree.type === "blob" && tree.path.includes("/")) // 제좜된 풀이(디렉토리 μ•„λž˜μ— μžˆλŠ” 파일)만 필터링
.map(parseSubmissionTree)
.filter((submission): submission is Submission => submission !== null);
},
};
}

const parseCohort = (teamName: string, prefix: string): Cohort => {
const cohort = parseInt(teamName.replace(prefix, ""), 10);
if (!isCohort(cohort)) {
throw new Error(`Invalid cohort number: ${cohort} from team ${teamName}`);
}
return cohort as Cohort;
};

const isCohort = (value: number): value is Cohort => {
return Number.isInteger(value) && value > 0;
// 기수(μ½”ν˜ΈνŠΈ)λŠ” λͺ…ν™•ν•˜κ²Œ 숫자둜 κ΅¬μ„±λ˜μ–΄ μžˆλ‹€κ³  κ°€μ •ν•œλ‹€.
return parseInt(teamName.replace(prefix, ""), 10);
};

const dropDuplicateMembers = (members: Member[]): Member[] => {
Expand All @@ -75,10 +68,6 @@ const dropDuplicateMembers = (members: Member[]): Member[] => {
return Array.from(memberMap.values());
};

const isRelevantTree = (tree: GitHubTree): boolean => {
return tree.type === "blob" && tree.path.includes("/");
};

const parseSubmissionTree = (tree: GitHubTree): Submission | null => {
const regex = /^([^/]+)\/([^.]+)\.([a-zA-Z0-9]+)$/;
const match = tree.path.toLocaleLowerCase().match(regex);
Expand Down

0 comments on commit d814bca

Please sign in to comment.