| Line 1... |
Line 1... |
| 1 |
/**
|
1 |
/**
|
| 2 |
*
|
2 |
*
|
| 3 |
*/
|
3 |
*/
|
| 4 |
package in.shop2020.serving.controllers;
|
4 |
package in.shop2020.serving.controllers;
|
| 5 |
|
5 |
|
| 6 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
6 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
| 7 |
import in.shop2020.serving.cache.EhcacheWrapper;
|
7 |
import in.shop2020.serving.cache.EhcacheWrapper;
|
| 8 |
import in.shop2020.serving.services.ContentServingService;
|
8 |
import in.shop2020.serving.services.ContentServingService;
|
| 9 |
import in.shop2020.serving.utils.SnippetType;
|
9 |
import in.shop2020.serving.utils.SnippetType;
|
| 10 |
import in.shop2020.thrift.clients.CatalogClient;
|
10 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 11 |
|
11 |
|
| Line 67... |
Line 67... |
| 67 |
String brandName = request.getParameter("brand");
|
67 |
String brandName = request.getParameter("brand");
|
| 68 |
//Right now if we have brand name, we can just send back data for all categories
|
68 |
//Right now if we have brand name, we can just send back data for all categories
|
| 69 |
if(brandName!=null){
|
69 |
if(brandName!=null){
|
| 70 |
categoryId = -1;
|
70 |
categoryId = -1;
|
| 71 |
}
|
71 |
}
|
| 72 |
in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
|
72 |
in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
|
| 73 |
this.items = client.getBestSellersCatalogIds(beginIndex, windowSize, brandName, categoryId);
|
73 |
this.items = client.getBestSellersCatalogIds(beginIndex, windowSize, brandName, categoryId);
|
| 74 |
setSnippets(items);
|
74 |
setSnippets(items);
|
| 75 |
return new DefaultHttpHeaders("index");
|
75 |
return new DefaultHttpHeaders("index");
|
| 76 |
}
|
76 |
}
|
| 77 |
|
77 |
|
| Line 92... |
Line 92... |
| 92 |
log.info("Using Cache.");
|
92 |
log.info("Using Cache.");
|
| 93 |
return new DefaultHttpHeaders("show");
|
93 |
return new DefaultHttpHeaders("show");
|
| 94 |
}
|
94 |
}
|
| 95 |
}
|
95 |
}
|
| 96 |
log.info("Getting best sellers from snippets.");
|
96 |
log.info("Getting best sellers from snippets.");
|
| 97 |
in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
|
97 |
in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
|
| 98 |
try {
|
98 |
try {
|
| 99 |
|
99 |
|
| 100 |
long count = client.getBestSellersCount();
|
100 |
long count = client.getBestSellersCount();
|
| 101 |
this.setTotalItems(count > 20 ? 20 : count);
|
101 |
this.setTotalItems(count > 20 ? 20 : count);
|
| 102 |
if(sourceId == -1){
|
102 |
if(sourceId == -1){
|
| Line 105... |
Line 105... |
| 105 |
this.items = client.getBestSellersCatalogIds(beginIndex, windowSize, null, -1);
|
105 |
this.items = client.getBestSellersCatalogIds(beginIndex, windowSize, null, -1);
|
| 106 |
setSnippets(items);
|
106 |
setSnippets(items);
|
| 107 |
if(sourceId == -1){
|
107 |
if(sourceId == -1){
|
| 108 |
showcasePageSnippetsCache.put(SHOWCASE_BEST_SELLERS_CACHE_KEY + beginIndex, this.snippets);
|
108 |
showcasePageSnippetsCache.put(SHOWCASE_BEST_SELLERS_CACHE_KEY + beginIndex, this.snippets);
|
| 109 |
}
|
109 |
}
|
| 110 |
} catch (InventoryServiceException e) {
|
110 |
} catch (CatalogServiceException e) {
|
| 111 |
log.error("Unable to get best sellers from inventory service.", e);
|
111 |
log.error("Unable to get best sellers from inventory service.", e);
|
| 112 |
} catch (TException e) {
|
112 |
} catch (TException e) {
|
| 113 |
log.error("Unable to get best sellers from inventory service.", e);
|
113 |
log.error("Unable to get best sellers from inventory service.", e);
|
| 114 |
}
|
114 |
}
|
| 115 |
return new DefaultHttpHeaders("show");
|
115 |
return new DefaultHttpHeaders("show");
|