Subversion Repositories SmartDukaan

Rev

Rev 5529 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5529 Rev 5945
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 69... Line 69...
69
        String brandName = request.getParameter("brand");
69
        String brandName = request.getParameter("brand");
70
        //Right now if we have brand name, we can just send back data for all categories
70
        //Right now if we have brand name, we can just send back data for all categories
71
        if(brandName != null){
71
        if(brandName != null){
72
            categoryId = -1;
72
            categoryId = -1;
73
        }
73
        }
74
    	in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
74
    	in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
75
    	this.items = client.getBestDealsCatalogIds(beginIndex, windowSize, brandName, categoryId);
75
    	this.items = client.getBestDealsCatalogIds(beginIndex, windowSize, brandName, categoryId);
76
    	setSnippets();
76
    	setSnippets();
77
    	return new DefaultHttpHeaders("index");
77
    	return new DefaultHttpHeaders("index");
78
    }
78
    }
79
 
79
 
Line 94... Line 94...
94
	            log.info("Using Cache.");
94
	            log.info("Using Cache.");
95
	            return new DefaultHttpHeaders("show");
95
	            return new DefaultHttpHeaders("show");
96
	        }
96
	        }
97
        }
97
        }
98
        log.info("Getting best deals from snippets.");
98
        log.info("Getting best deals from snippets.");
99
    	in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
99
    	in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
100
    	try {
100
    	try {
101
    		long count = client.getBestDealsCount();
101
    		long count = client.getBestDealsCount();
102
			this.setTotalItems(count > 20 ? 20 : count);
102
			this.setTotalItems(count > 20 ? 20 : count);
103
			if(sourceId == -1){
103
			if(sourceId == -1){
104
				showcasePageSnippetsCache.put(SHOWCASE_BEST_DEALS_COUNT_CACHE_KEY, this.totalItems);
104
				showcasePageSnippetsCache.put(SHOWCASE_BEST_DEALS_COUNT_CACHE_KEY, this.totalItems);
Line 106... Line 106...
106
			this.items = client.getBestDealsCatalogIds(beginIndex, windowSize, null, -1);
106
			this.items = client.getBestDealsCatalogIds(beginIndex, windowSize, null, -1);
107
			setSnippets();
107
			setSnippets();
108
			if(sourceId == -1){
108
			if(sourceId == -1){
109
				showcasePageSnippetsCache.put(SHOWCASE_BEST_DEALS_CACHE_KEY + beginIndex, this.snippets);
109
				showcasePageSnippetsCache.put(SHOWCASE_BEST_DEALS_CACHE_KEY + beginIndex, this.snippets);
110
			}
110
			}
111
		} catch (InventoryServiceException e) {
111
		} catch (CatalogServiceException e) {
112
			log.error("Unable to get best deals from inventory service.", e);
112
			log.error("Unable to get best deals from inventory service.", e);
113
		} catch (TException e) {
113
		} catch (TException e) {
114
			log.error("Unable to get best deals from inventory service.", e);
114
			log.error("Unable to get best deals from inventory service.", e);
115
		}
115
		}
116
    	return new DefaultHttpHeaders("show");
116
    	return new DefaultHttpHeaders("show");