- TypeScript 소스 파일 내 모든 import 구문에서 불필요한 `.js` 확장자를 제거하여 모듈 참조 방식을 표준화했습니다. - 핸들러, 서비스, 리포지토리 및 테스트 코드를 포함한 프로젝트 전반의 import 경로를 일관성 있게 정리했습니다.
21 lines
657 B
TypeScript
21 lines
657 B
TypeScript
import type { Scope } from "../repositories/scoreboardCacheRepository";
|
|
import type { RankSnapshot } from "../types/panit";
|
|
|
|
export function computePercentile(rank: number, totalCount: number): number {
|
|
if (totalCount <= 0) return 0;
|
|
return Math.round((1 - (rank - 1) / totalCount) * 100);
|
|
}
|
|
|
|
export function deltaFor(
|
|
snapshot: RankSnapshot | undefined,
|
|
currentRank: number,
|
|
scope: Scope
|
|
): number | null {
|
|
if (!snapshot) return null;
|
|
if (scope.kind === "overall") return snapshot.overall - currentRank;
|
|
if (snapshot.teamCode !== scope.teamCode || snapshot.team === undefined) {
|
|
return null;
|
|
}
|
|
return snapshot.team - currentRank;
|
|
}
|