Skip to content

Commit

Permalink
Merge pull request #72 from Kusitms-29th-Meetup-TeamE/fix/71/page-count
Browse files Browse the repository at this point in the history
Fix: 페이지 카운트 수정
  • Loading branch information
Jeongho427 authored May 22, 2024
2 parents 8405029 + 6817681 commit fba7ade
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ public ReadActivitiesRes findActivities(ReadActivitiesReq activitiesReq) {
long page = activitiesReq.getPage();
long offset = page * ACTIVITY_PAGE_SIZE;
long limit = ACTIVITY_PAGE_SIZE;
/*AgencyType agencyType = null;
if (activitiesReq.getAgencyType() != null) {
agencyType = AgencyType.of(activitiesReq.getAgencyType());
}*/

List<AgencyType> agencyTypes = activitiesReq.getAgencyTypes().stream()
.map(AgencyType::of)
.collect(Collectors.toList());
Expand All @@ -87,25 +84,24 @@ public ReadActivitiesRes findActivities(ReadActivitiesReq activitiesReq) {
//관심활동 목록 필터링으로 조회
public ReadActivitiesRes findlikedActivities(ReadActivitiesReq activitiesReq) {
Long userId = SecurityContextProvider.getAuthenticatedUserId();
Long page = activitiesReq.getPage();
long page = activitiesReq.getPage();
long offset = page * ACTIVITY_PAGE_SIZE;
long limit = ACTIVITY_PAGE_SIZE;
/*AgencyType agencyType = null;
if (activitiesReq.getAgencyType() != null) {
agencyType = AgencyType.of(activitiesReq.getAgencyType());
}*/

List<AgencyType> agencyTypes = activitiesReq.getAgencyTypes().stream()
.map(AgencyType::of)
.collect(Collectors.toList());
List<Personality> personalities = activitiesReq.getPersonalities().stream()
.map(Personality::of)
.collect(Collectors.toList());
//long totalCount = activityRepository.countActivities(agencyType, personalities);
long pageCount = activityRepository.countActivities(agencyTypes, personalities) / ACTIVITY_PAGE_SIZE + 1; // 전체 페이지 수 계산

//long pageCount = activityRepository.countActivities(agencyTypes, personalities) / ACTIVITY_PAGE_SIZE + 1; // 전체 페이지 수 계산

List<Long> likedActivityIds = activityLikeRepository.findLikedActivityIdsByUserId(userId);
Set<Long> likedActivityIdsSet = new HashSet<>(likedActivityIds);

long pageCount = likedActivityIds.size() / ACTIVITY_PAGE_SIZE + 1;

List<Activity> activities = activityRepository.findLikedActivities(userId, offset, limit, agencyTypes, personalities);
List<ActivitySummaryRes> activitySummaries = activities.stream()
.map(activity -> ActivitySummaryRes.of(activity, likedActivityIdsSet.contains(activity.getId())))
Expand Down

0 comments on commit fba7ade

Please sign in to comment.