Skip to content

refactor(backend): es-toolkit 기반으로 유틸성 함수 개선#248

Merged
kubrickcode merged 1 commit intodevelop/shlee/refactorfrom
develop/shlee/247
Nov 25, 2025
Merged

refactor(backend): es-toolkit 기반으로 유틸성 함수 개선#248
kubrickcode merged 1 commit intodevelop/shlee/refactorfrom
develop/shlee/247

Conversation

@kubrickcode
Copy link
Owner

@kubrickcode kubrickcode commented Nov 25, 2025

lodash 의존성을 es-toolkit으로 전환하여 번들 크기를 줄이고 타입 안전성을 개선

주요 변경사항:

  • lodash(70KB) 제거 → es-toolkit(~16KB) 도입
  • keyBy, groupBy, orderBy, sum, sumBy 함수 활용
  • 순차 async for-of 루프를 Promise.all + sum으로 병렬화하여 성능 개선
  • any 타입을 제네릭으로 대체하여 타입 안전성 강화
  • if-else 조건 분기를 nullish coalescing으로 간소화

fix #247

@gemini-code-assist
Copy link

Summary of Changes

Hello @kubrickcode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 Pull Request는 백엔드 코드베이스의 유틸리티 함수를 리팩토링하는 데 중점을 둡니다. 주요 목표는 lodash 라이브러리를 더 가볍고 타입 친화적인 es-toolkit으로 교체하여 애플리케이션의 번들 크기를 줄이고 전반적인 성능과 코드 품질을 향상시키는 것입니다. 또한, 비동기 로직을 병렬화하고 타입 정의를 개선하여 코드의 효율성과 유지보수성을 높였습니다.

Highlights

  • 의존성 전환: 번들 크기 감소 및 타입 안전성 개선을 위해 lodash 의존성을 es-toolkit으로 전환했습니다. lodash(70KB)를 제거하고 es-toolkit(~16KB)을 도입하여 상당한 크기 최적화를 달성했습니다.
  • 유틸리티 함수 활용: es-toolkit의 keyBy, groupBy, orderBy, sum, sumBy 함수를 활용하여 코드 가독성과 효율성을 높였습니다.
  • 성능 개선: 순차적인 async for-of 루프를 Promise.all과 sum을 사용하는 병렬 처리 방식으로 변경하여 비동기 작업의 성능을 개선했습니다.
  • 타입 안전성 강화: 코드 전반에 걸쳐 any 타입을 제네릭으로 대체하고 명시적인 타입을 도입하여 타입 안전성을 강화했습니다.
  • 코드 간소화: if-else 조건 분기를 nullish coalescing 연산자(??)로 간소화하여 코드를 더 깔끔하고 읽기 쉽게 만들었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubrickcode
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

lodash 의존성을 es-toolkit으로 전환하여 번들 크기를 줄이고 타입 안전성을 개선하는 훌륭한 리팩터링입니다. Promise.all을 사용한 비동기 작업 병렬화로 성능을 개선하고, nullish coalescing 같은 최신 TypeScript 기능을 활용하여 코드를 간소화하는 등 변경 사항이 매우 잘 적용되었습니다. 전반적으로 코드의 가독성과 유지보수성이 크게 향상되었습니다. 다만, 옵셔널 체이닝 사용과 관련하여 런타임 오류를 유발할 수 있는 치명적인 버그를 발견했으며, 매직 넘버 사용에 대한 사소한 스타일 문제를 지적했습니다. 이 부분들을 수정하면 더욱 완벽한 PR이 될 것입니다.

}
const userReward = userRewardByItemId[itemId];
return {
averageQuantity: userReward?.averageQuantity.toNumber() ?? averageQuantity.toNumber(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

userReward?.averageQuantityundefined일 수 있는데, 이 경우 .toNumber()를 호출하면 런타임 에러가 발생합니다. ?? 연산자를 사용하기 전에 userReward?.averageQuantityundefined일 때의 기본값을 먼저 제공해야 합니다. 이렇게 하면 undefined에 대해 .toNumber()를 호출하는 것을 방지할 수 있습니다.

Suggested change
averageQuantity: userReward?.averageQuantity.toNumber() ?? averageQuantity.toNumber(),
averageQuantity: (userReward?.averageQuantity ?? averageQuantity).toNumber(),

lodash 의존성을 es-toolkit으로 전환하여 번들 크기를 줄이고 타입 안전성을 개선

주요 변경사항:
- lodash(70KB) 제거 → es-toolkit(~16KB) 도입
- keyBy, groupBy, orderBy, sum, sumBy 함수 활용
- 순차 async for-of 루프를 Promise.all + sum으로 병렬화하여 성능 개선
- any 타입을 제네릭으로 대체하여 타입 안전성 강화
- if-else 조건 분기를 nullish coalescing으로 간소화

fix #247
@kubrickcode
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

lodashes-toolkit으로 성공적으로 전환하여 번들 크기를 줄이고 타입 안전성을 개선한 훌륭한 리팩터링입니다. Promise.all을 사용한 비동기 작업 병렬화는 상당한 성능 향상을 가져옵니다. Nullish coalescing 등 최신 ES 기능을 활용하여 코드가 더 간결하고 현대적으로 개선되었습니다. 저장소 스타일 가이드 준수와 관련하여 클래스 메서드의 알파벳순 정렬 등 몇 가지 사소한 문제를 발견했습니다. 전반적으로 매우 품질 높은 기여라고 생각합니다.

@kubrickcode kubrickcode merged commit b8f41ab into develop/shlee/refactor Nov 25, 2025
7 checks passed
@kubrickcode kubrickcode deleted the develop/shlee/247 branch November 25, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant