Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YS-130] feat: 기간이 지난 공고 state 변경 스케줄링 구현 #35

Merged
merged 23 commits into from
Jan 17, 2025

Conversation

chock-cho
Copy link
Member

@chock-cho chock-cho commented Jan 15, 2025

💡 작업 내용

  • 기간이 지난 experiment_post 에 대해, 매일 자정마다 자동으로 recuritDone = false 를 설정해주는 스케줄러를 구현하였습니다.
  • API 확장성과 클러스터링 기능을 제공하는 Quartz 라이브러리를 채택하여 구현하였습니다.
  • QueryDsl로 다소 복잡할 수 있는 쿼리를 메서드화 하였습니다.
    image
  • 추가) TimeZone 설정을 명시화하여 로그를 찍어봤을 때, 서버의 기본 JVM 시간 및 Quartz 시간대도 Asia/Seoul 로 설정됨을 확인했습니다😊

✅ 셀프 체크리스트

  • PR 제목을 형식에 맞게 작성했나요?
  • 브랜치 전략에 맞는 브랜치에 PR을 올리고 있나요?
  • 테스트는 잘 통과했나요?
  • 빌드에 성공했나요?
  • 본인을 assign 해주세요.
  • 해당 PR에 맞는 label을 붙여주세요.

🙋🏻‍ 확인해주세요

  • 업데이트가 잘되었는지 확인하기 위해, DB 상의 몇 개의 데이터의 상태가 변했는지 명시해주는 방식으로 구현했는데, 관련하여 의견 궁금합니다!

🔗 Jira 티켓


https://yappsocks.atlassian.net/browse/YS-130

🔗 Jira 티켓


https://yappsocks.atlassian.net/browse/YS-130

chock-cho and others added 20 commits January 14, 2025 16:13
- 필터링, offset-based 페이지네이션 위한 도메인 모델 정의:
  `CustomFilter` `Pagination`
- querydsl 라이브러리 사용하여 동적 쿼리 작성, 다양한 필터 조건 처리
- entity.enum → entity.enums: 예약어 인식 이슈로 패키지 명 변경
- ExperimentPostMapper에서 입출력값 dto ↔ 유즈케이스 input/output으로
  전환
- 실험공고 필터링 API 유즈케이스에 대한 유닛 테스트코드 작성
- 코드 리뷰 피드백 반영
- import` 문 활용  → 유즈케이스 내부 변환 로직의 경우 중복 네이밍 이슈로 필요
- 검증 로직 service로 책임 이전 → SRP 원칙 준수
- 필터링 중 `method` → `matchType` 으로 변수명 변경
- 유즈케이스 내부의 `@Schema` 어노테이션 제거
- '실험 방법' = '대면/비대면/전체'로 필터링하도록 수정
- '전체' 선택 시 쿼리에 미반영되도록 쿼리부분 수정
- 만료된 게시글의 상태를 1일 주기로 정기적 업데이트하기 위해 Quartz
  스케줄러 구현
- `ExpiredExperimentPostJob` 에서 `ExperimentPostCustomRepository` 직접
  호출→ `recruitDone` 상태 업데이트
- `ExpiredExperimentPostJob` 에서 `ExperimentPostService` 를 호출하여
  로직 처리
- 재사용성, API 확장성과 비즈니스 로직 캡슐화를 위한 코드 리팩터링
- 로깅 추가: 스케줄링 작업 완료 시 recuritDone = true 된 ExperimentPost
  수 기록
@chock-cho chock-cho self-assigned this Jan 15, 2025
@chock-cho chock-cho added the ✨ FEATURE 기능 추가 label Jan 15, 2025
@chock-cho chock-cho requested a review from Ji-soo708 January 15, 2025 20:54
Ji-soo708
Ji-soo708 previously approved these changes Jan 17, 2025
Copy link
Member

@Ji-soo708 Ji-soo708 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 구현하신 부분을 꼼꼼하게 확인했는데, 의존성 방향이 클린 아키텍처 원칙에 맞게 잘 설정된 것 같아 바로 approve합니다. 👍
코멘트를 남긴 부분만 다시 한 번 체크해주시면 감사하겠습니다~

@@ -48,6 +48,7 @@ dependencies {
implementation("org.mariadb.jdbc:mariadb-java-client:2.7.3")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0")
implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
implementation("org.springframework.boot:spring-boot-starter-quartz")
Copy link
Member

Choose a reason for hiding this comment

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

저도 기간이 지난 공고 state를 변경하는 작업은 가볍다고 생각해서 quartz 구현 방식이 좋은 거 같아요 👍

Comment on lines 68 to 70



Copy link
Member

Choose a reason for hiding this comment

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

사소한 부분이지만 파일 끝에는 한 줄만 남겨주시면 감사합니다! ☺️

Copy link
Member Author

Choose a reason for hiding this comment

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

좋은 피드백 감사합니다!!

Comment on lines +22 to +24
.withIdentity("expired_experiment_post_trigger")
.withSchedule(
CronScheduleBuilder.dailyAtHourAndMinute(0, 0)
Copy link
Member

Choose a reason for hiding this comment

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

Quartz 스케줄러는 기본적으로 시스템의 기본 시간대를 따르는데 설정하지 않아도 한국 시간대에 동작할 수 있지만, 안정성과 명시성을 위해 명확히 타임존을 설정하는 것은 어떨까요??

Suggested change
.withIdentity("expired_experiment_post_trigger")
.withSchedule(
CronScheduleBuilder.dailyAtHourAndMinute(0, 0)
.withIdentity("expired_experiment_post_trigger")
.withSchedule(
CronScheduleBuilder.dailyAtHourAndMinute(0, 0)
.inTimeZone(TimeZone.getTimeZone("Asia/Seoul"))

Copy link
Member Author

Choose a reason for hiding this comment

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

저도 해당 부분을 저희 '대규모 설계 시스템 기초 스터디'에서 7주차(어제자 발표)로 공부한 TimeZone 이슈에서 명시할 필요성이 있다는 것을 느꼈습니다!
인사이트 있는 피드백 정말 감사합니다! 반영하겠습니다.

@Ji-soo708 Ji-soo708 changed the title [YS-130] 기간이 지난 공고 state 변경 스케줄링 구현 [YS-130] feat: 기간이 지난 공고 state 변경 스케줄링 구현 Jan 17, 2025
- 서버의 JVM 시간대와 Quartz 라이브러리의 시간대를 `Asia/Seoul` 로
  명시화하였습니다.
Ji-soo708
Ji-soo708 previously approved these changes Jan 17, 2025
Copy link
Member

@Ji-soo708 Ji-soo708 left a comment

Choose a reason for hiding this comment

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

LGTM! 수정사항 잘 반영된 거 확인했습니다~ 수고하셨어요! 👏

@chock-cho chock-cho merged commit 5158eae into dev Jan 17, 2025
3 checks passed
@chock-cho chock-cho deleted the feat/YS-130 branch January 17, 2025 12:18
Ji-soo708 added a commit that referenced this pull request Jan 26, 2025
* feat: implement experiment post lists filtering API with pagination

- 필터링, offset-based 페이지네이션 위한 도메인 모델 정의:
  `CustomFilter` `Pagination`
- querydsl 라이브러리 사용하여 동적 쿼리 작성, 다양한 필터 조건 처리
- entity.enum → entity.enums: 예약어 인식 이슈로 패키지 명 변경
- ExperimentPostMapper에서 입출력값 dto ↔ 유즈케이스 input/output으로
  전환

* test: add test codes for experiment post filtering API usecase

- 실험공고 필터링 API 유즈케이스에 대한 유닛 테스트코드 작성

* fix: add unreflected source files

* fix: update '_ALL' option to return all posts on that region

* fix: update code review's feedbacks

- 코드 리뷰 피드백 반영
- import` 문 활용  → 유즈케이스 내부 변환 로직의 경우 중복 네이밍 이슈로 필요
- 검증 로직 service로 책임 이전 → SRP 원칙 준수
- 필터링 중 `method` → `matchType` 으로 변수명 변경
- 유즈케이스 내부의 `@Schema` 어노테이션 제거

* refact: delegate domain converter to ExperimentMapper

* refact: rename usecase's class to suffix

* refact: rename API endpoint query parameter  →

* test: update test codes for refactoring

* refact: update misunderstood requirement to meet the busniess logic

- '실험 방법' = '대면/비대면/전체'로 필터링하도록 수정
- '전체' 선택 시 쿼리에 미반영되도록 쿼리부분 수정

* fix: add ExperimentMapperTest codes to meet the test coverage

* refact: refactor validator codes to upgrade readability

* feat: add WebSecurityConfig codes to allow permit without authentication

* fix: fix QueryDSL generation issues with entity and enum

* test: add test codes to meet the test coverage guage

* feat: implement experiment state scheudler using Quartz libraries

- 만료된 게시글의 상태를 1일 주기로 정기적 업데이트하기 위해 Quartz
  스케줄러 구현
- `ExpiredExperimentPostJob` 에서 `ExperimentPostCustomRepository` 직접
  호출→ `recruitDone` 상태 업데이트

* feat: add scheduling jobs to application layer for clean architecture

- `ExpiredExperimentPostJob` 에서 `ExperimentPostService` 를 호출하여
  로직 처리
- 재사용성, API 확장성과 비즈니스 로직 캡슐화를 위한 코드 리팩터링
- 로깅 추가: 스케줄링 작업 완료 시 recuritDone = true 된 ExperimentPost
  수 기록

* test: add test codes for experiment post status scheduler

* refact: delete final lines to specify eof line

* feat: specify Quartz time zone `Asia/Seoul`

- 서버의 JVM 시간대와 Quartz 라이브러리의 시간대를 `Asia/Seoul` 로
  명시화하였습니다.

---------

Co-authored-by: jisu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ FEATURE 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants