Skip to content

Commit aad6fde

Browse files
Commented out redis support for the search suggestion service and added support for productname query parameter
1 parent 2121495 commit aad6fde

File tree

9 files changed

+52
-30
lines changed

9 files changed

+52
-30
lines changed

client/src/actions/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export const getDataViaAPI = (type, uri, subsequent_request) => async dispatch =
257257
log.info(`[ACTION]: invokeAndDispatchAPIData Calling API = ${uri}.`)
258258

259259
if (uri) {
260-
uri = uri.replace(/\s/g, '')
260+
// uri = uri.replace(/\s/g, '')
261261
let responseError = false
262262
const response = await commonServiceAPI.get(uri)
263263
.catch(err => {
@@ -291,20 +291,28 @@ export const loadFilterAttributes = filterQuery => async dispatch => {
291291
log.info(`[ACTION]: loadFilterAttributes Calling Filter API filterQuery = ${filterQuery}`)
292292

293293
if (filterQuery) {
294-
let removedSpacesFromFilterQuery = filterQuery.replace(/\s/g, '')
295-
let uri = `/filter${removedSpacesFromFilterQuery}`
294+
try {
295+
if(filterQuery.split("=")[1].localeCompare("productname") === 0 ) {
296+
// currently we do not support productname parameter for filter API.
297+
filterQuery="?q=category=all"
298+
}
299+
} catch (e) {
300+
log.info('Unable to find productname parameter')
301+
}
302+
303+
let uri = `/filter${filterQuery}`
296304
const response = await commonServiceAPI.get(uri);
297305
if (response != null) {
298306
log.trace(`[ACTION]: Filter = ${JSON.stringify(response.data)}`)
299307

300-
const extractRequiredParams = removedSpacesFromFilterQuery.slice(3)
308+
const extractRequiredParams = filterQuery.slice(3)
301309

302310
dispatch({
303311
type: LOAD_FILTER_ATTRIBUTES,
304312
payload: JSON.parse(JSON.stringify(
305313
{
306314
...response.data,
307-
"query": removedSpacesFromFilterQuery.slice(3)
315+
"query": filterQuery.slice(3)
308316
}))
309317
});
310318

client/src/components/routes/navbar/searchBar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ function SearchBar(props) {
3232
props.handleClose();
3333
}
3434

35+
setValue('')
36+
3537
// search is selected
3638
if(reason === "select-option" && selectedValue != null) {
37-
log.info("Search is selected.... value = "
38-
+ selectedValue)
3939
for(let index = 0; index < searchSuggestions.data.length; ++index) {
4040
if(searchSuggestions.data[index].keyword.length === selectedValue.length
4141
&& searchSuggestions.data[index].keyword.localeCompare(selectedValue) === 0) {

server/common-data-service/src/main/java/com/ujjaval/ecommerce/commondataservice/controller/CommonDataController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public ResponseEntity<?> getHomeTabsDataResponse() {
8383

8484
@GetMapping(value = "/filter", params = "q")
8585
public ResponseEntity<?> getFilterAttributesByProducts(@RequestParam("q") String queryParams) {
86-
8786
FilterAttributesResponse result = commonDataService.getFilterAttributesByProducts(queryParams);
8887

8988
if (result == null) {

server/common-data-service/src/main/java/com/ujjaval/ecommerce/commondataservice/dao/sql/info/queryhelpers/ProductQueryHelper.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
public class ProductQueryHelper {
1515
enum QueryType {
16-
genders, apparels, brands, prices, category, sortby, page;
16+
genders, apparels, brands, prices, category, sortby, page, productname;
1717
}
1818

1919
private final int NEWEST = 1;
@@ -46,6 +46,21 @@ public void prepareConditionListById(HashMap<Integer, Object> mapParameters, Str
4646
}
4747
}
4848

49+
public void prepareConditionListByName(HashMap<Integer, Object> mapParameters, String data,
50+
MapParameterKey mapParametersKey,
51+
List<String> conditions, String field) {
52+
List<String> tempList = new ArrayList<>();
53+
54+
for (String val : data.split(",")) {
55+
mapParameters.put(mapParametersKey.getKey(), val);
56+
tempList.add("?" + mapParametersKey.getKey());
57+
mapParametersKey.increment();
58+
}
59+
if (data.length() > 0) {
60+
conditions.add(String.format("(%s IN (%s))", field, String.join(",", tempList)));
61+
}
62+
}
63+
4964
public ParamsToQueryContext getParamsToQueryMap(HashMap<String, String> conditionMap) {
5065
if (conditionMap == null) {
5166
return null;
@@ -107,6 +122,10 @@ public ParamsToQueryContext getParamsToQueryMap(HashMap<String, String> conditio
107122
case page:
108123
pageInfo = entry.getValue().split(",");
109124
break;
125+
case productname:
126+
prepareConditionListByName(mapParams, entry.getValue(), mapParametersKey,
127+
conditions, "p.name");
128+
break;
110129
default:
111130
System.out.println("UnsupportedType");
112131
}
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
setup:
2-
addons:
3-
- plan: heroku-redis
4-
as: DATABASE
51
build:
62
docker:
73
web: Dockerfile-prod

server/search-suggestion-service/pom.xml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
<groupId>org.springframework.boot</groupId>
2424
<artifactId>spring-boot-starter-actuator</artifactId>
2525
</dependency>
26-
<dependency>
27-
<groupId>org.springframework.boot</groupId>
28-
<artifactId>spring-boot-starter-data-redis</artifactId>
29-
</dependency>
3026
<dependency>
3127
<groupId>org.springframework.boot</groupId>
3228
<artifactId>spring-boot-starter-web</artifactId>
@@ -45,17 +41,22 @@
4541
<optional>true</optional>
4642
</dependency>
4743

48-
<dependency>
49-
<groupId>redis.clients</groupId>
50-
<artifactId>jedis</artifactId>
51-
<version>3.2.0</version>
52-
<type>jar</type>
53-
</dependency>
44+
<!-- <dependency>-->
45+
<!-- <groupId>org.springframework.boot</groupId>-->
46+
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
47+
<!-- </dependency>-->
5448

55-
<dependency>
56-
<groupId>org.springframework.boot</groupId>
57-
<artifactId>spring-boot-starter-cache</artifactId>
58-
</dependency>
49+
<!-- <dependency>-->
50+
<!-- <groupId>redis.clients</groupId>-->
51+
<!-- <artifactId>jedis</artifactId>-->
52+
<!-- <version>3.2.0</version>-->
53+
<!-- <type>jar</type>-->
54+
<!-- </dependency>-->
55+
56+
<!-- <dependency>-->
57+
<!-- <groupId>org.springframework.boot</groupId>-->
58+
<!-- <artifactId>spring-boot-starter-cache</artifactId>-->
59+
<!-- </dependency>-->
5960

6061
<dependency>
6162
<groupId>org.springframework.boot</groupId>

server/search-suggestion-service/src/main/java/com/ujjaval/ecommerce/searchsuggestionservice/dto/SearchSuggestionKeywordInfo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.ujjaval.ecommerce.searchsuggestionservice.dto;
22

3-
import lombok.AllArgsConstructor;
43
import lombok.Getter;
54
import lombok.Setter;
65

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
spring.data.redis.repositories.enabled=false
1+
#spring.data.redis.repositories.enabled=false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
spring.application.name=search-suggestion-service
22
server.port=${PORT}
33
spring.profiles.active=${ACTIVE_PROFILE}
4-
spring.cache.redis.time-to-live=10
4+
#spring.cache.redis.time-to-live=10

0 commit comments

Comments
 (0)