Skip to content

Search by catalog number in user's collection. #1100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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 @@ -72,6 +72,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import static ru.mystamps.web.common.ControllerUtils.redirectTo;

Expand Down Expand Up @@ -470,6 +471,8 @@ public String processAskForm(
public String searchSeriesByCatalog(
@RequestParam(name = "catalogNumber", defaultValue = "") String catalogNumber,
@RequestParam(name = "catalogName", defaultValue = "") String catalogName,
@RequestParam(name = "inCollection", defaultValue = "false") Boolean inCollection,
@CurrentUser Integer currentUserId,
Model model,
Locale userLocale,
RedirectAttributes redirectAttributes) {
Expand Down Expand Up @@ -504,6 +507,18 @@ public String searchSeriesByCatalog(
series = Collections.emptyList();
break;
}

if (Features.SEARCH_IN_COLLECTION.isActive()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. Could you add a comment before this `if``:

// @todo #1100 Optimize a search within user's collection

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction, there was a wrong number:

// @todo #1098 Optimize a search within user's collection

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added it in 742b7d8 commit.

&& inCollection
&& currentUserId != null) {
series = series
.stream()
.filter(
e -> collectionService.isSeriesInCollection(currentUserId, e.getId())
)
.collect(Collectors.toList());
}

model.addAttribute("searchResults", series);

return "series/search_result";
Expand Down