Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
goulven authored and goulven committed Sep 8, 2024
1 parent 361d8a9 commit f313ef4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void sanitizeVertical(VerticalConfig vertical) {

// TODO : Performance, could parallelize
// Note : a strong choice to rely on categories, to replay aggregation process from unmapped / unverticalized items
dataRepository.getProductsMatchingCategories(vertical) .forEach(p -> {
dataRepository.getProductsMatchingCategoriesOrVerticalId(vertical) .forEach(p -> {
try {
batchAgg.onProduct(p);
dataRepository.index(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ public BatchService(AggregationFacadeService aggregationFacadeService,
// TODO : From conf
public void batch() {


// TODO (p1, design) : Here the sanitisation pass, that must applies on all matching categories and verticals with already defined ID
// at least to unset the no more matching categories
// BUT have to work on it on 2 passes which applies on 2 distinct datasets, this one as first with full hot memory on the "
//This is initial submission, batching the products to update catégories
aggregationFacadeService.sanitizeAllVerticals();



logger.info("Starting batch");

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ public void onProduct(Product data, VerticalConfig vConf) throws AggregationSkip
ProductI18nElements tConf = e.getValue();

// Computing url
String urlSuffix = StringUtils.stripAccents(computePrefixedText(data, tConf.getUrl(), "-"));
urlSuffix = StringUtils.normalizeSpace(urlSuffix).replace(' ', '-');
data.getNames().getUrl().put(lang, data.gtin() + "-" + urlSuffix);
// TODO(conf,p2) : Should allow override from conf
if (null == data.getNames().getUrl().get(lang)) {
String urlSuffix = StringUtils.stripAccents(computePrefixedText(data, tConf.getUrl(), "-"));
urlSuffix = StringUtils.normalizeSpace(urlSuffix).replace(' ', '-');
data.getNames().getUrl().put(lang, data.gtin() + "-" + urlSuffix);
}

// h1Title
data.getNames().getH1Title().put(lang, computePrefixedText(data, tConf.getH1Title(), " "));
// metaDescription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public void onProduct(Product data, VerticalConfig vConf) throws AggregationSkip
////////////////////////////
// Setting vertical from category
////////////////////////////
data.setVertical(null);
VerticalConfig vertical = verticalService.getVerticalForCategories(data.getDatasourceCategories());
if (null != vertical) {
if ( null != data.getVertical() && !vertical.getId().equals(data.getVertical())) {
Expand All @@ -80,11 +79,11 @@ public void onProduct(Product data, VerticalConfig vConf) throws AggregationSkip
data.setVertical(null);
}

// Setting no vertical if no category
if (data.getDatasourceCategories().size() == 0) {
dedicatedLogger.info("No category in {}, removing vertical", data);
data.setVertical(null);
}
// // Setting no vertical if no category
// if (data.getDatasourceCategories().size() == 0) {
// dedicatedLogger.info("No category in {}, removing vertical", data);
// data.setVertical(null);
// }


// TODO : Disabling google taxonomy for now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ProductRepository() {
* @param v
* @return
*/
public Stream<Product> getProductsMatchingCategories(VerticalConfig v) {
public Stream<Product> getProductsMatchingCategoriesOrVerticalId(VerticalConfig v) {
Criteria c = new Criteria("datasourceCategories").in(v.getMatchingCategories())
// TODO : Add exclusion
// .and(new Criteria("datasourceCategories").notIn(v.getMatchingCategories()))
Expand Down

0 comments on commit f313ef4

Please sign in to comment.