From d6152498d2c9c55cd19cf65bfbd5fa902b5f5c1c Mon Sep 17 00:00:00 2001 From: Alex Bogdanovski Date: Mon, 16 Sep 2024 16:47:12 +0300 Subject: [PATCH] fixed query filter for questions with no accepted answer, when applied through the filter drawer --- .../com/erudika/scoold/controllers/QuestionsController.java | 4 +++- src/main/resources/templates/questions.vm | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/erudika/scoold/controllers/QuestionsController.java b/src/main/java/com/erudika/scoold/controllers/QuestionsController.java index 3620f34e..f6d117e1 100755 --- a/src/main/java/com/erudika/scoold/controllers/QuestionsController.java +++ b/src/main/java/com/erudika/scoold/controllers/QuestionsController.java @@ -189,6 +189,8 @@ public String applyFilter(@RequestParam(required = false) String sortby, if (!StringUtils.isBlank(typeFilter)) { HttpUtils.setRawCookie("questions-type-filter", typeFilter, req, res, "Strict", (int) TimeUnit.DAYS.toSeconds(365)); + } else { + HttpUtils.removeStateParam("questions-type-filter", req, res); } savePagerToCookie(req, res, p); HttpUtils.setRawCookie("questions-view-compact", compactViewEnabled, @@ -451,7 +453,7 @@ private String getQueryWithPossibleExtension(String query, HttpServletRequest re queryExt = StringUtils.trimToEmpty(HttpUtils.getCookieValue(req, "questions-type-filter")); } if (!queryExt.isBlank()) { - return query.equals("*") ? queryExt : query + " AND (" + queryExt + ")"; + return query.equals("*") ? queryExt : query + " AND (" + Utils.urlDecode(queryExt) + ")"; } return query; } diff --git a/src/main/resources/templates/questions.vm b/src/main/resources/templates/questions.vm index eee93352..3e0809a6 100755 --- a/src/main/resources/templates/questions.vm +++ b/src/main/resources/templates/questions.vm @@ -221,7 +221,7 @@ #macro(filterselected $prop) #if($questionsTypeFilter == $prop)selected#end #end - #set($unacceptedQuery = "properties.answercount:[1 TO *] NOT properties.answerid:[* TO *]" ) + #set($unacceptedQuery = $utils.urlEncode("properties.answercount:[1 TO *] NOT properties.answerid:[* TO *]") )