인덱스 API 통계 부분 실 데이터 적용
This commit is contained in:
@@ -48,6 +48,7 @@ public class IndexController {
|
|||||||
model.addAttribute("hashtags", hashTags);
|
model.addAttribute("hashtags", hashTags);
|
||||||
|
|
||||||
// 인덱스 페이지 하단 통계
|
// 인덱스 페이지 하단 통계
|
||||||
|
model.addAttribute("statisticsVisible", statistics.isVisible());
|
||||||
model.addAttribute("approvedOrgCount", statistics.getApprovedOrgCount());
|
model.addAttribute("approvedOrgCount", statistics.getApprovedOrgCount());
|
||||||
model.addAttribute("serviceCount", statistics.getActiveAppCount());
|
model.addAttribute("serviceCount", statistics.getActiveAppCount());
|
||||||
model.addAttribute("totalApiCount", statistics.getTotalApiCount());
|
model.addAttribute("totalApiCount", statistics.getTotalApiCount());
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class IndexStatisticsDTO {
|
public class IndexStatisticsDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 통계 섹션 노출 여부
|
||||||
|
* PortalProperty의 main.statistics.display 값으로 설정 (기본값: true)
|
||||||
|
*/
|
||||||
|
@Builder.Default
|
||||||
|
private boolean visible = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API 활용 기업 수
|
* API 활용 기업 수
|
||||||
* 법인으로 등록되고 정상 상태인 기업의 수
|
* 법인으로 등록되고 정상 상태인 기업의 수
|
||||||
|
|||||||
+26
-2
@@ -6,6 +6,7 @@ import com.eactive.apim.portal.apps.main.dto.IndexStatisticsDTO;
|
|||||||
import com.eactive.apim.portal.apps.user.repository.PortalOrgRepository;
|
import com.eactive.apim.portal.apps.user.repository.PortalOrgRepository;
|
||||||
import com.eactive.apim.portal.portalorg.entity.PortalOrgEnums.ApprovalStatus;
|
import com.eactive.apim.portal.portalorg.entity.PortalOrgEnums.ApprovalStatus;
|
||||||
import com.eactive.apim.portal.portalorg.entity.PortalOrgEnums.OrgStatus;
|
import com.eactive.apim.portal.portalorg.entity.PortalOrgEnums.OrgStatus;
|
||||||
|
import com.eactive.apim.portal.portalproperty.service.PortalPropertyService;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -24,9 +25,13 @@ public class IndexStatisticsService {
|
|||||||
|
|
||||||
private static final long CACHE_TTL_HOURS = 1;
|
private static final long CACHE_TTL_HOURS = 1;
|
||||||
private static final String APP_STATUS_ACTIVE = "1";
|
private static final String APP_STATUS_ACTIVE = "1";
|
||||||
|
private static final String PORTAL_PROPERTY_GROUP = "Portal";
|
||||||
|
private static final String STATISTICS_DISPLAY_KEY = "main.statistics.display";
|
||||||
|
private static final String DISPLAY_YES = "Y";
|
||||||
|
|
||||||
private final PortalOrgRepository portalOrgRepository;
|
private final PortalOrgRepository portalOrgRepository;
|
||||||
private final CredentialRepository credentialRepository;
|
private final CredentialRepository credentialRepository;
|
||||||
|
private final PortalPropertyService portalPropertyService;
|
||||||
|
|
||||||
// 캐시된 통계 데이터
|
// 캐시된 통계 데이터
|
||||||
private volatile IndexStatisticsDTO cachedStatistics;
|
private volatile IndexStatisticsDTO cachedStatistics;
|
||||||
@@ -68,6 +73,9 @@ public class IndexStatisticsService {
|
|||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// 0. 노출 여부 확인 (PortalProperty에서 조회, 기본값: Y)
|
||||||
|
boolean visible = isStatisticsVisible();
|
||||||
|
|
||||||
// 1. API 활용 기업 수: 정상 상태이고 승인 완료된 기관 수
|
// 1. API 활용 기업 수: 정상 상태이고 승인 완료된 기관 수
|
||||||
int approvedOrgCount = (int) portalOrgRepository.countByOrgStatusAndApprovalStatus(
|
int approvedOrgCount = (int) portalOrgRepository.countByOrgStatusAndApprovalStatus(
|
||||||
OrgStatus.ACTIVE, ApprovalStatus.COMPLETED);
|
OrgStatus.ACTIVE, ApprovalStatus.COMPLETED);
|
||||||
@@ -91,6 +99,7 @@ public class IndexStatisticsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cachedStatistics = IndexStatisticsDTO.builder()
|
cachedStatistics = IndexStatisticsDTO.builder()
|
||||||
|
.visible(visible)
|
||||||
.approvedOrgCount(approvedOrgCount)
|
.approvedOrgCount(approvedOrgCount)
|
||||||
.activeAppCount(activeAppCount)
|
.activeAppCount(activeAppCount)
|
||||||
.totalApiCount(totalApiCount)
|
.totalApiCount(totalApiCount)
|
||||||
@@ -99,14 +108,15 @@ public class IndexStatisticsService {
|
|||||||
lastAggregatedTime = LocalDateTime.now();
|
lastAggregatedTime = LocalDateTime.now();
|
||||||
|
|
||||||
long elapsed = System.currentTimeMillis() - startTime;
|
long elapsed = System.currentTimeMillis() - startTime;
|
||||||
log.info("인덱스 페이지 통계 집계 완료 - 소요시간: {}ms, 기업: {}, 앱: {}, API: {}",
|
log.info("인덱스 페이지 통계 집계 완료 - 소요시간: {}ms, 노출: {}, 기업: {}, 앱: {}, API: {}",
|
||||||
elapsed, approvedOrgCount, activeAppCount, totalApiCount);
|
elapsed, visible, approvedOrgCount, activeAppCount, totalApiCount);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("인덱스 페이지 통계 집계 실패", e);
|
log.error("인덱스 페이지 통계 집계 실패", e);
|
||||||
// 기존 캐시가 없는 경우 기본값 설정
|
// 기존 캐시가 없는 경우 기본값 설정
|
||||||
if (cachedStatistics == null) {
|
if (cachedStatistics == null) {
|
||||||
cachedStatistics = IndexStatisticsDTO.builder()
|
cachedStatistics = IndexStatisticsDTO.builder()
|
||||||
|
.visible(true)
|
||||||
.approvedOrgCount(0)
|
.approvedOrgCount(0)
|
||||||
.activeAppCount(0)
|
.activeAppCount(0)
|
||||||
.totalApiCount(0)
|
.totalApiCount(0)
|
||||||
@@ -115,6 +125,20 @@ public class IndexStatisticsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PortalProperty에서 통계 노출 여부 조회
|
||||||
|
* 프로퍼티가 없으면 기본값 "Y"를 DB에 저장 후 반환
|
||||||
|
*/
|
||||||
|
private boolean isStatisticsVisible() {
|
||||||
|
String displayValue = portalPropertyService.getOrCreateProperty(
|
||||||
|
PORTAL_PROPERTY_GROUP,
|
||||||
|
STATISTICS_DISPLAY_KEY,
|
||||||
|
DISPLAY_YES,
|
||||||
|
"인덱스 페이지 하단 통계 섹션 노출 여부 (Y: 노출, N: 숨김)"
|
||||||
|
);
|
||||||
|
return DISPLAY_YES.equalsIgnoreCase(displayValue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 캐시 강제 갱신 (관리자용)
|
* 캐시 강제 갱신 (관리자용)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -250,7 +250,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- API 활용 현황 섹션 -->
|
<!-- API 활용 현황 섹션 -->
|
||||||
<section class="api-stats-section">
|
<section class="api-stats-section" th:if="${statisticsVisible}">
|
||||||
<div class="stats-background"></div>
|
<div class="stats-background"></div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="section-header">
|
<div class="section-header">
|
||||||
|
|||||||
Reference in New Issue
Block a user