Skip to content

Commit 8be4664

Browse files
authored
Merge pull request #376 from mosu-dev/develop
prod
2 parents fe64008 + 59ba93d commit 8be4664

File tree

9 files changed

+124
-105
lines changed

9 files changed

+124
-105
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: 코드 안정성
3+
about: 코드 안정성 대한 요청
4+
title: "[🛠 코드 안정성] "
5+
labels: 코드 안정성
6+
assignees: ""
7+
---
8+
9+
## ✨ 문제 요약
10+
11+
현재 발생한 문제나 개선이 필요한 부분에 대해 한 줄로 명확하게 요약해주세요.
12+
13+
----
14+
15+
-
16+
17+
## 🐛 어떤 문제가 발생했나요?
18+
19+
자세한 문제 상황을 설명해주세요. 버그, 성능 저하, 코드의 문제점(Code Smell) 등 어떤 종류의 안정성 문제인지 구체적으로 서술합니다.
20+
21+
----
22+
23+
-
24+
25+
## 🕹️ 어떻게 재현할 수 있나요?
26+
27+
문제를 재현할 수 있는 구체적인 순서를 단계별로 작성해주세요.
28+
만약 재현이 어렵다면, 어떤 상황에서 주로 발생하는지 설명해주세요. (ex. 특정 API에 요청이 몰릴 때)
29+
30+
----
31+
32+
1. `이 단계에서는...`
33+
2. `그 다음에는...`
34+
3. `그러면 문제가 발생합니다.`
35+
36+
## 🤔 기대 결과와 실제 결과는 무엇이었나요?
37+
38+
- **기대 결과**: 원래라면 어떻게 동작해야 했는지 설명해주세요.
39+
- **실제 결과**: 실제로 어떻게 동작했는지, 어떤 오류가 발생했는지 설명해주세요.
40+
41+
----
42+
43+
- **기대 결과**:
44+
- **실제 결과**:
45+
46+
## 📎 근거 자료
47+
48+
문제 상황을 파악하는 데 도움이 되는 모든 자료를 첨부해주세요.
49+
50+
- **에러 로그**: `(에러 로그를 여기에 붙여넣어 주세요)`
51+
- **스크린샷**: `(스크린샷 이미지 첨부)`
52+
- **관련 코드**: 문제가 발생한 코드의 일부 또는 파일 경로
53+
54+
----
55+
56+
-
57+
58+
## 📝 추가 사항
59+
60+
이슈 해결에 도움이 될 만한 추가 정보나 고려해야 할 조건이 있다면 자유롭게 기입해주세요.
61+
62+
----
63+
64+
-

src/main/java/life/mosu/mosuserver/application/application/ApplicationService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import life.mosu.mosuserver.presentation.application.dto.ApplicationResponse;
2020
import life.mosu.mosuserver.presentation.application.dto.CreateApplicationResponse;
2121
import life.mosu.mosuserver.presentation.application.dto.ExamApplicationRequest;
22+
import life.mosu.mosuserver.presentation.application.dto.SchoolApplicationCountResponse;
2223
import life.mosu.mosuserver.presentation.common.FileRequest;
2324
import lombok.RequiredArgsConstructor;
2425
import lombok.extern.slf4j.Slf4j;
@@ -103,4 +104,9 @@ private CreateApplicationResponse handleApplication(
103104
public List<ApplicationResponse> getApplications(Long userId) {
104105
return getApplicationsStepProcessor.process(userId);
105106
}
107+
108+
@Transactional(readOnly = true)
109+
public List<SchoolApplicationCountResponse> getPaidApplicationCountBySchool() {
110+
return applicationJpaRepository.findPaidApplicationCountBySchool();
111+
}
106112
}

src/main/java/life/mosu/mosuserver/application/application/cron/ApplicationFailureLogDomainArchiveExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@RequiredArgsConstructor
2323
public class ApplicationFailureLogDomainArchiveExecutor implements DomainArchiveExecutor {
2424

25-
private final static Duration DURATION_HOURS_STANDARD = Duration.ofHours(1);
25+
private final static Duration DURATION_HOURS_STANDARD = Duration.ofHours(48);
2626
private final static int BATCH_SIZE = 500;
2727

2828
private final ApplicationFailureLogFactory applicationFailureLogFactory;
@@ -63,7 +63,7 @@ public String getName() {
6363
}
6464

6565
private List<ApplicationJpaEntity> findFailedApplications() {
66-
Instant threshold = Instant.now().minus(DURATION_HOURS_STANDARD); // 3 hours ago
66+
Instant threshold = Instant.now().minus(DURATION_HOURS_STANDARD);
6767
LocalDateTime time = LocalDateTime.ofInstant(threshold, ZoneId.systemDefault());
6868
return applicationJpaRepository.findFailedApplications(time);
6969
}

src/main/java/life/mosu/mosuserver/domain/application/repository/ApplicationJpaRepository.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.time.LocalDateTime;
44
import java.util.List;
55
import life.mosu.mosuserver.domain.application.entity.ApplicationJpaEntity;
6+
import life.mosu.mosuserver.presentation.application.dto.SchoolApplicationCountResponse;
67
import org.springframework.data.jpa.repository.JpaRepository;
78
import org.springframework.data.jpa.repository.Modifying;
89
import org.springframework.data.jpa.repository.Query;
@@ -29,6 +30,21 @@ AND a.status IN ('PENDING', 'ABORT')
2930
""")
3031
List<ApplicationJpaEntity> findAllByUserId(@Param("userId") Long userId);
3132

33+
@Query("""
34+
SELECT new life.mosu.mosuserver.presentation.application.dto.SchoolApplicationCountResponse(
35+
e.schoolName,
36+
COUNT(a.id)
37+
)
38+
FROM ApplicationJpaEntity a
39+
JOIN ExamApplicationJpaEntity ea ON ea.applicationId = a.id
40+
JOIN ExamJpaEntity e ON e.id = ea.examId
41+
WHERE a.deleted = false
42+
AND a.status = 'APPROVED'
43+
GROUP BY e.schoolName
44+
ORDER BY e.schoolName
45+
""")
46+
List<SchoolApplicationCountResponse> findPaidApplicationCountBySchool();
47+
3248
@Modifying
3349
@Query(value = """
3450
UPDATE application a

src/main/java/life/mosu/mosuserver/global/filter/Whitelist.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public enum Whitelist {
5050
//USER find-password
5151
USER_FIND_PASSWORD("/api/v1/user/me/find-password", WhitelistMethod.POST),
5252

53-
APPLICATION_GUEST("/api/v1/applications/guest", WhitelistMethod.ALL);
54-
53+
APPLICATION_GUEST("/api/v1/applications/guest", WhitelistMethod.ALL),
54+
APPLICATION_PAID("/api/v1/applications/schools/paid-count",WhitelistMethod.ALL);
5555
private static final List<ExceptionRule> AUTH_REQUIRED_EXCEPTIONS = List.of(
5656
new ExceptionRule("/api/v1/exam-application", WhitelistMethod.GET)
5757
);
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package life.mosu.mosuserver.infra.cron.job;
22

33

4-
import java.time.LocalDateTime;
5-
import java.util.List;
6-
import life.mosu.mosuserver.global.support.cron.LogCleanupExecutor;
74
import life.mosu.mosuserver.infra.cron.annotation.CronJob;
8-
import lombok.RequiredArgsConstructor;
95
import lombok.extern.slf4j.Slf4j;
106
import org.quartz.DisallowConcurrentExecution;
117
import org.quartz.Job;
@@ -17,22 +13,22 @@
1713
name = "logCleanupJob"
1814
)
1915
@DisallowConcurrentExecution
20-
@RequiredArgsConstructor
16+
//@RequiredArgsConstructor
2117
public class LogCleanupJob implements Job {
2218

23-
private final List<LogCleanupExecutor> cleanups;
19+
// private final List<LogCleanupExecutor> cleanups;
2420

2521
@Override
2622
public void execute(JobExecutionContext context) {
27-
LocalDateTime threshold = LocalDateTime.now().minusMonths(3);
28-
for (LogCleanupExecutor cleanup : cleanups) {
29-
try {
30-
int deleted = cleanup.deleteLogsBefore(threshold);
31-
log.info("[LogCleanupJob] Deleted total {} logs older than {}", deleted, threshold);
32-
} catch (Exception e) {
33-
log.error("[LogCleanupJob] Error during log cleanup: {}",
34-
cleanup.getClass().getSimpleName(), e);
35-
}
36-
}
23+
// LocalDateTime threshold = LocalDateTime.now().minusMonths(3);
24+
// for (LogCleanupExecutor cleanup : cleanups) {
25+
// try {
26+
// int deleted = cleanup.deleteLogsBefore(threshold);
27+
// log.info("[LogCleanupJob] Deleted total {} logs older than {}", deleted, threshold);
28+
// } catch (Exception e) {
29+
// log.error("[LogCleanupJob] Error during log cleanup: {}",
30+
// cleanup.getClass().getSimpleName(), e);
31+
// }
32+
// }
3733
}
3834
}

src/main/java/life/mosu/mosuserver/presentation/application/ApplicationController.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import life.mosu.mosuserver.presentation.application.dto.ApplicationRequest;
1111
import life.mosu.mosuserver.presentation.application.dto.ApplicationResponse;
1212
import life.mosu.mosuserver.presentation.application.dto.CreateApplicationResponse;
13+
import life.mosu.mosuserver.presentation.application.dto.SchoolApplicationCountResponse;
1314
import lombok.RequiredArgsConstructor;
1415
import lombok.extern.slf4j.Slf4j;
1516
import org.springframework.http.HttpStatus;
@@ -74,4 +75,12 @@ public ResponseEntity<ApiResponseWrapper<List<ApplicationResponse>>> getApplicat
7475
return ResponseEntity.ok(
7576
ApiResponseWrapper.success(HttpStatus.OK, "신청 내역 조회 성공", responses));
7677
}
78+
79+
//학교별 결제된 신청 수 조회
80+
@GetMapping("/schools/paid-count")
81+
public ResponseEntity<ApiResponseWrapper<List<SchoolApplicationCountResponse>>> getPaidApplicationCountBySchool() {
82+
List<SchoolApplicationCountResponse> responses = applicationService.getPaidApplicationCountBySchool();
83+
return ResponseEntity.ok(
84+
ApiResponseWrapper.success(HttpStatus.OK, "학교별 결제된 신청 수 조회 성공", responses));
85+
}
7786
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package life.mosu.mosuserver.presentation.application.dto;
2+
3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
5+
@Schema(description = "학교별 결제된 신청 수 응답")
6+
public record SchoolApplicationCountResponse(
7+
@Schema(description = "학교명", example = "서울고등학교")
8+
String schoolName,
9+
10+
@Schema(description = "결제된 신청 수", example = "25")
11+
Long paidApplicationCount
12+
) {
13+
}

src/test/java/life/mosu/mosuserver/infra/cron/job/LogCleanupJobTest.java

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)