Skip to content

Commit

Permalink
#317 [refactor] TimeSlotRetrieve -> TimeBlock으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
sohyundoh committed Aug 24, 2024
1 parent cf752a8 commit 1773755
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asap.server.presentation.controller.dto.response;

import com.asap.server.service.time.dto.retrieve.TimeSlotRetrieveDto;
import com.asap.server.service.time.dto.retrieve.TimeBlockRetrieveDto;
import lombok.Builder;

import java.util.List;
Expand All @@ -11,7 +11,7 @@ public record TimeSlotDto (
List<String> userNames,
int colorLevel
) {
public static List<TimeSlotDto> of(List<TimeSlotRetrieveDto> retrieveDtos) {
public static List<TimeSlotDto> of(List<TimeBlockRetrieveDto> retrieveDtos) {
return retrieveDtos.stream().map(
dto -> new TimeSlotDto(dto.time(), dto.userNames(), dto.colorLevel())
).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.asap.server.service.time.MeetingTimeRecommendService;
import com.asap.server.service.time.UserMeetingScheduleService;
import com.asap.server.service.time.dto.retrieve.AvailableDatesRetrieveDto;
import com.asap.server.service.time.dto.retrieve.TimeSlotRetrieveDto;
import com.asap.server.service.time.dto.retrieve.TimeBlockRetrieveDto;
import com.asap.server.service.time.dto.retrieve.TimeTableRetrieveDto;
import com.asap.server.service.time.vo.BestMeetingTimeVo;
import com.asap.server.service.time.vo.BestMeetingTimeWithUsers;
Expand All @@ -27,10 +27,12 @@
import java.util.stream.Collectors;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Slf4j
@RequiredArgsConstructor
public class MeetingRetrieveService {
private final MeetingRepository meetingRepository;
Expand Down Expand Up @@ -110,9 +112,9 @@ public TimeTableRetrieveDto getTimeTable(final Long meetingId, final Long userId

private List<AvailableDatesRetrieveDto> getAvailableDatesDto(final Long meetingId, final int totalUserCount) {
List<TimeBlockVo> timeBlockVos = userMeetingScheduleService.getTimeBlocks(meetingId);

Map<LocalDate, List<TimeSlotRetrieveDto>> timeSlotDtoMappedByDate = getTimeTableMapFromTimeBlockVo(timeBlockVos, totalUserCount);

log.info("Query----- Start");
Map<LocalDate, List<TimeBlockRetrieveDto>> timeSlotDtoMappedByDate = getTimeTableMapFromTimeBlockVo(timeBlockVos, totalUserCount);
log.info("Query----- Start");
return timeSlotDtoMappedByDate.keySet().stream().map(
date -> AvailableDatesRetrieveDto.of(
date,
Expand All @@ -121,11 +123,11 @@ private List<AvailableDatesRetrieveDto> getAvailableDatesDto(final Long meetingI
).toList();
}

private Map<LocalDate, List<TimeSlotRetrieveDto>> getTimeTableMapFromTimeBlockVo(final List<TimeBlockVo> timeBlockVo, final int totalUserCount) {
private Map<LocalDate, List<TimeBlockRetrieveDto>> getTimeTableMapFromTimeBlockVo(final List<TimeBlockVo> timeBlockVo, final int totalUserCount) {
return timeBlockVo.stream()
.collect(Collectors.groupingBy(
TimeBlockVo::availableDate,
Collectors.mapping(t -> new TimeSlotRetrieveDto(
Collectors.mapping(t -> new TimeBlockRetrieveDto(
t.timeSlot().getTime(),
userRetrieveService.getUserNamesFromId(t.userIds()),
setColorLevel(totalUserCount, t.userIds().size())
Expand All @@ -135,7 +137,7 @@ private Map<LocalDate, List<TimeSlotRetrieveDto>> getTimeTableMapFromTimeBlockVo
));
}

public int setColorLevel(final int memberCount, final int availableUserCount) {
private int setColorLevel(final int memberCount, final int availableUserCount) {
double ratio = (double) availableUserCount / memberCount;

if (ratio <= 0.2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public record AvailableDatesRetrieveDto(
String month,
String day,
String dayOfWeek,
List<TimeSlotRetrieveDto> timeSlots
List<TimeBlockRetrieveDto> timeSlots
) {
public static AvailableDatesRetrieveDto of(final LocalDate date, final List<TimeSlotRetrieveDto> timeSlots) {
public static AvailableDatesRetrieveDto of(final LocalDate date, final List<TimeBlockRetrieveDto> timeSlots) {
return new AvailableDatesRetrieveDto(
DateUtil.getMonth(date),
DateUtil.getDay(date),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

public record TimeSlotRetrieveDto(
public record TimeBlockRetrieveDto(
String time,
List<String> userNames,
int colorLevel
Expand Down

0 comments on commit 1773755

Please sign in to comment.