Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ActivitiesByMemberAndKeywordInMonthResponse readActivitiesByMemberAndKeyw
LocalDateTime endDayOfMonth = TimeUtil.toEndDayOfMonth(yearMonth);
List<ActivityWithTitleAndSavedTimeResponse> activities = activityDao.findActivitiesByMemberAndKeywordInMonth(member.getId(), firstDayOfMonth, endDayOfMonth, keywordCategory);
TotalSavedTimeAndActivityCountByKeywordInMonth totalSavedTimeAndActivityCountByKeywordInMonth = activityDao.findTotalSavedTimeAndActivityCountByKeywordInMonth(member.getId(), firstDayOfMonth, endDayOfMonth, keywordCategory);
Keyword keyword = Keyword.create(keywordCategory, imageConverter.convertToTransparent30ImageUrl(keywordCategory));
Keyword keyword = Keyword.create(keywordCategory, imageConverter.convertToImageUrl(keywordCategory));
return new ActivitiesByMemberAndKeywordInMonthResponse(
totalSavedTimeAndActivityCountByKeywordInMonth.totalSavedTimeByKeywordInMonth(),
totalSavedTimeAndActivityCountByKeywordInMonth.totalActivityCountByKeywordInMonth(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import spring.backend.activity.domain.value.Keyword.Category;
import spring.backend.activity.dto.request.MonthlyActivityOverviewRequest;
import spring.backend.activity.dto.response.MonthlyActivityCountByKeywordResponse;
import spring.backend.activity.dto.response.MonthlyActivityOverviewResponse;
import spring.backend.activity.dto.response.MonthlySavedTimeAndActivityCountResponse;
import spring.backend.activity.infrastructure.persistence.jpa.value.KeywordJpaValue;
import spring.backend.activity.query.dao.ActivityDao;
import spring.backend.core.converter.ImageConverter;
import spring.backend.core.util.TimeUtil;
import spring.backend.member.domain.entity.Member;

Expand All @@ -24,12 +27,22 @@ public class ReadMonthlyActivityOverviewService {

private final ActivityDao activityDao;

private final ImageConverter imageConverter;

public MonthlyActivityOverviewResponse readMonthlyActivityOverview(Member member, MonthlyActivityOverviewRequest monthlyActivityOverviewRequest) {
YearMonth yearMonth = YearMonth.of(monthlyActivityOverviewRequest.year(), monthlyActivityOverviewRequest.month());
LocalDateTime startDayOfMonth = TimeUtil.toStartDayOfMonth(yearMonth);
LocalDateTime endDayOfMonth = TimeUtil.toEndDayOfMonth(yearMonth);
MonthlySavedTimeAndActivityCountResponse monthlySavedTimeAndActivityCountResponse = activityDao.findMonthlyTotalSavedTimeAndTotalCount(member.getId(), startDayOfMonth, endDayOfMonth);
List<MonthlyActivityCountByKeywordResponse> activityByKeywordSummaryResponses = activityDao.findMonthlyActivitiesByKeywordSummary(member.getId(), startDayOfMonth, endDayOfMonth);
return new MonthlyActivityOverviewResponse(member.getUpdatedAt().getYear(), member.getUpdatedAt().getMonth(), monthlySavedTimeAndActivityCountResponse, activityByKeywordSummaryResponses);
List<MonthlyActivityCountByKeywordResponse> updatedActivityByKeywordSummaryResponses = activityByKeywordSummaryResponses.stream()
.map(response -> {
Category category = response.keyword().getCategory();
String imageUrl = imageConverter.convertToTransparent30ImageUrl(category);
KeywordJpaValue updatedKeyword = KeywordJpaValue.create(category, imageUrl);
return new MonthlyActivityCountByKeywordResponse(updatedKeyword, response.activityCount());
})
.toList();
return new MonthlyActivityOverviewResponse(member.getUpdatedAt().getYear(), member.getUpdatedAt().getMonth(), monthlySavedTimeAndActivityCountResponse, updatedActivityByKeywordSummaryResponses);
}
}