@bytebrand/export-cars 1.21.31 → 1.21.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/export-cars",
3
- "version": "1.21.31",
3
+ "version": "1.21.32",
4
4
  "description": "",
5
5
  "author": "bytebrand",
6
6
  "license": "UNLICENSED",
@@ -34,7 +34,7 @@ export class GoogleExporter implements Exporter {
34
34
 
35
35
  for (const data of chunk.data) {
36
36
  const car = await googleTransformer.transform(data);
37
- if (data.images.length > 0)
37
+ if (car)
38
38
  await googleXmlBuilder.addItem(car);
39
39
  this.carService.counter.countCar(data.images);
40
40
  }
@@ -3,6 +3,7 @@ import { CarDescriptionFactory, DescriptionTypeEnum } from '@bytebrand/car-descr
3
3
  import { DataSchemes } from '@bytebrand/car-schema';
4
4
  import { TranslatorExtended } from '@bytebrand/schema-tools';
5
5
  import { de, deVehicleDetailsPage, deVehicleProps } from '@bytebrand/i18n-dictionaries';
6
+ import { ImboImageResponseInterface } from '@bytebrand/chunkable';
6
7
  import { Injectable } from '@nestjs/common';
7
8
  import { ConfigService, ImagesService, TransformerService, UserService } from '../services';
8
9
  import { GoogleXmlItem } from '../interfaces';
@@ -26,6 +27,9 @@ export class GoogleTransformer {
26
27
  }
27
28
 
28
29
  async transform({ car, images }: { car: DataSchemes.Car; images: Array<any> }): Promise<GoogleXmlItem> {
30
+ if (!this.checkCarValidity(car, images))
31
+ return null
32
+
29
33
  const carId = toString(get(car, '_id', ''));
30
34
  const transformedImages = await this.imageService.getImages(
31
35
  car,
@@ -77,6 +81,16 @@ export class GoogleTransformer {
77
81
  };
78
82
  }
79
83
 
84
+ private checkCarValidity(car: DataSchemes.Car, images: ImboImageResponseInterface[]) {
85
+ if (images.length === 0)
86
+ return false
87
+
88
+ if (!this.mapBodyStyle(car))
89
+ return false
90
+
91
+ return true
92
+ }
93
+
80
94
  private getTitle(car: DataSchemes.Car): string {
81
95
  const model = toString(get(car, 'mainData.model', ''));
82
96