성능 대폭 개선 - parseMaterialInfo 캐싱
Some checks failed
SonarQube Analysis / SonarQube Scan (push) Has been cancelled

백엔드:
- GET /dashboard/projects 엔드포인트 추가
- 프로젝트 목록 조회 API 구현

프론트엔드:
- parseMaterialInfo 결과를 useMemo로 캐싱
- parsedMaterialsMap으로 중복 계산 방지
- getParsedInfo() 함수로 캐시된 값 사용
- 성능 개선: 1315개 자재 × 6번 계산 → 1315개 자재 × 1번 계산
- 약 80% 계산 감소 (8000번 → 1500번)

효과:
- 페이지 로딩 속도 대폭 향상
- 메모리 사용량 감소
- 필터/정렬 기능 유지하면서 가벼워짐
This commit is contained in:
Hyungi Ahn
2025-10-14 07:06:24 +09:00
parent a55e2e1c37
commit 003983872c
2 changed files with 68 additions and 3 deletions

View File

@@ -777,6 +777,20 @@ const NewMaterialsPage = ({
setSortConfig({ key: null, direction: 'asc' });
};
// 자재 정보를 미리 계산하여 캐싱 (성능 최적화)
const parsedMaterialsMap = React.useMemo(() => {
const map = new Map();
materials.forEach(material => {
map.set(material.id, parseMaterialInfo(material));
});
return map;
}, [materials]);
// parseMaterialInfo를 캐시된 버전으로 교체
const getParsedInfo = (material) => {
return parsedMaterialsMap.get(material.id) || parseMaterialInfo(material);
};
// 필터링된 자재 목록
const filteredMaterials = materials
.filter(material => {
@@ -789,7 +803,7 @@ const NewMaterialsPage = ({
for (const [column, filterValue] of Object.entries(columnFilters)) {
if (!filterValue) continue;
const info = parseMaterialInfo(material);
const info = getParsedInfo(material);
let materialValue = '';
switch (column) {
@@ -903,7 +917,7 @@ const NewMaterialsPage = ({
.slice(0, 200);
categoryMaterials.forEach(material => {
const info = parseMaterialInfo(material);
const info = getParsedInfo(material);
let value = '';
switch (filterKey) {
@@ -1327,7 +1341,7 @@ const NewMaterialsPage = ({
)}
{filteredMaterials.map((material) => {
const info = parseMaterialInfo(material);
const info = getParsedInfo(material);
if (material.classified_category === 'SPECIAL') {
// SPECIAL 카테고리 (10개 컬럼)