diff --git a/commons/src/main/java/org/open4goods/commons/dao/ProductRepository.java b/commons/src/main/java/org/open4goods/commons/dao/ProductRepository.java index bc202ca09..e6f831042 100644 --- a/commons/src/main/java/org/open4goods/commons/dao/ProductRepository.java +++ b/commons/src/main/java/org/open4goods/commons/dao/ProductRepository.java @@ -165,19 +165,19 @@ public Stream exportAll(String vertical) { /** * Export all aggregated data, corresponding to the given Barcodes - * + * * @return */ public Stream exportAll(BarcodeType... barcodeTypes) { - + Criteria criteria = new Criteria("gtinInfos.upcType").in((Object[]) barcodeTypes); CriteriaQuery query = new CriteriaQuery(criteria); - + return elasticsearchOperations.searchForStream(query, Product.class, current_index).stream() .map(SearchHit::getContent); } - - + + public Stream searchInValidPrices(String query, final String indexName, int from, int to) { Criteria c = new Criteria().expression(query).and(getRecentPriceQuery()); @@ -400,15 +400,15 @@ public void addToFullindexationQueue(Collection data) { public void addToPartialIndexationQueue(Collection data) { logger.info("Queuing {} products", data.size()); - + data.forEach(e -> { - + try { partialProductQueue.put(e) ; } catch (Exception e1) { logger.error("!!!! exception, cannot enqueue product {}",e); } - + }); } @@ -585,19 +585,19 @@ public Long countMainIndexHavingRecentPrices() { return elasticsearchOperations.count(query, current_index); } - @Cacheable(keyGenerator = CacheConstants.KEY_GENERATOR, cacheNames = CacheConstants.ONE_HOUR_LOCAL_CACHE_NAME) - public Long countMainIndexHavingRecentUpdate() { - CriteriaQuery query = new CriteriaQuery(getRecentPriceQuery()); - return elasticsearchOperations.count(query, current_index); - } - @Cacheable(cacheNames = CacheConstants.ONE_DAY_LOCAL_CACHE_NAME) public long countItemsByBarcodeType(BarcodeType... barcodeTypes) { Criteria criteria = new Criteria("gtinInfos.upcType").in((Object[]) barcodeTypes); CriteriaQuery query = new CriteriaQuery(criteria); return elasticsearchOperations.count(query, current_index); } - + + @Cacheable(keyGenerator = CacheConstants.KEY_GENERATOR, cacheNames = CacheConstants.ONE_HOUR_LOCAL_CACHE_NAME) + public Long countMainIndexHavingRecentUpdate() { + CriteriaQuery query = new CriteriaQuery(getRecentPriceQuery()); + return elasticsearchOperations.count(query, current_index); + } + @Cacheable(keyGenerator = CacheConstants.KEY_GENERATOR, cacheNames = CacheConstants.ONE_HOUR_LOCAL_CACHE_NAME) public Map byTaxonomy() {