Skip to content

Commit

Permalink
Merge pull request #287 from MOONSHOT-Team/feature/#286
Browse files Browse the repository at this point in the history
[Fix] #286 - 소셜 쿼리 오류 수정 및 닉네임 정규표현식 수정
  • Loading branch information
0lynny authored Jun 4, 2024
2 parents 363f17a + c15c585 commit 11e1fd6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import static org.moonshot.validator.IndexValidator.isSameIndex;

import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.moonshot.common.model.Period;
Expand Down Expand Up @@ -144,7 +142,10 @@ public HistoryResponseDto getObjectiveHistory(final Long userId, final Integer y
@Transactional(readOnly = true)
public List<SocialOKRResponseDto> getObjectiveSocial() {
List<Objective> objectives = objectiveRepository.findSocialObjectives();
Set<Long> objectiveIds = new LinkedHashSet<>();

return objectives.stream()
.filter(objective -> objectiveIds.add(objective.getId()))
.map(SocialOKRResponseDto::of)
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.moonshot.constants;

public class RegexConstants {
public static final String nicknameRegex = "^[a-zA-Z0-9가-힣]{1,7}$";
public static final String nicknameRegex = "^[a-zA-Z0-9ㄱ-ㅎㅏ-ㅣ가-힣]{1,7}$";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
import static org.moonshot.keyresult.model.QKeyResult.keyResult;
import static org.moonshot.objective.model.QObjective.objective;
import static org.moonshot.task.model.QTask.task;
import static org.moonshot.user.model.QUser.user;

import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.impl.JPAQueryFactory;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.Hibernate;
Expand Down Expand Up @@ -72,12 +78,12 @@ private OrderSpecifier<?> order(Criteria criteria) {

@Override
public List<Objective> findSocialObjectives() {
return queryFactory.selectFrom(objective).distinct()
.join(objective.user).fetchJoin()
return queryFactory.selectFrom(objective)
.join(objective.user, user).fetchJoin()
.leftJoin(objective.keyResultList, keyResult).fetchJoin()
.leftJoin(keyResult.taskList, task)
.where(objective.isPublic.eq(true))
.orderBy(objective.heartCount.desc(), objective.id.desc(), keyResult.idx.asc(), task.id.asc())
.orderBy(objective.heartCount.desc(), objective.id.desc(), keyResult.idx.asc(), task.idx.asc())
.limit(10)
.fetch();
}
Expand Down

0 comments on commit 11e1fd6

Please sign in to comment.