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

Refactor: 5차 코드리뷰 기반 개편 (안부전화 요일 변환, URL 환경변수화 관련) 구현 #185

Merged
merged 5 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ jobs:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Run deployment script on server
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.SERVER_IP }} 'bash /home/ubuntu/deploy.sh'
ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.SERVER_IP }} 'SLACK_WEBHOOK_URL=$SLACK_WEBHOOK_URL bash /home/ubuntu/deploy.sh'
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.Map;

@Service
public class HelloCallPriceService {

private static final int PRICE_PER_ONE_MINUTE = 50;
private static final Map<String, DayOfWeek> DAY_NAME_MAP = Map.of(
"월", DayOfWeek.MONDAY,
"화", DayOfWeek.TUESDAY,
"수", DayOfWeek.WEDNESDAY,
"목", DayOfWeek.THURSDAY,
"금", DayOfWeek.FRIDAY,
"토", DayOfWeek.SATURDAY,
"일", DayOfWeek.SUNDAY
);

public HelloCallPriceResponse calculateHelloCallPrice(HelloCallPriceRequest helloCallPriceRequest) {
int totalServiceCount = calculateTotalServiceCount(helloCallPriceRequest);
Expand All @@ -37,16 +47,11 @@ public int calculateTotalServiceCount(HelloCallPriceRequest helloCallPriceReques
}

private DayOfWeek convertDayStringToDayOfWeek(String dayName) {
return switch (dayName) {
case "월" -> DayOfWeek.MONDAY;
case "화" -> DayOfWeek.TUESDAY;
case "수" -> DayOfWeek.WEDNESDAY;
case "목" -> DayOfWeek.THURSDAY;
case "금" -> DayOfWeek.FRIDAY;
case "토" -> DayOfWeek.SATURDAY;
case "일" -> DayOfWeek.SUNDAY;
default -> throw new BadRequestException("잘못된 dayName 입니다 : " + dayName);
};
DayOfWeek dayOfWeek = DAY_NAME_MAP.get(dayName);
if (dayOfWeek == null) {
throw new BadRequestException("잘못된 dayName 입니다 : " + dayName);
}
return dayOfWeek;
}

private int countOccurrencesOfDay(LocalDate startDate, LocalDate endDate, DayOfWeek targetDayOfWeek) {
Expand Down