Skip to content

Commit

Permalink
Update sortBy parameter and conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ozdentarikcan committed Dec 16, 2024
1 parent 5acc44c commit 0c1d2c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,9 @@ public Page<Question> searchQuestions(
}

PageRequest pageable = PageRequest.of(page - 1, pageSize);
if (Objects.equals(sortBy, "default") || Objects.equals(currentUser, null)) {
if (Objects.equals(sortBy, "default") || Objects.equals(sortBy, null) || Objects.equals(currentUser, null) || ) {
return questionRepository.searchQuestions(query, tagIds, difficulty, pageable);
} else {

List<Long> authorIds = currentUser.getFollowing().stream()
.map(User::getId) // Map each User to its ID
.collect(Collectors.toList()); // Collect the IDs into a List
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/SearchQuestionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const SearchQuestionsList = () => {
q: params.get("q") ?? "",
pageSize,
...(difficulty && { difficulty }),
sortBy: params.get("sortBy") ?? "recommended"
},
});

Expand Down

0 comments on commit 0c1d2c9

Please sign in to comment.