@bytebrand/export-cars 1.21.30 → 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/dist/exporters/google.exporter.js +1 -1
- package/dist/exporters/google.exporter.js.map +1 -1
- package/dist/transformers/google.transformer.d.ts +1 -0
- package/dist/transformers/google.transformer.js +10 -2
- package/dist/transformers/google.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/exporters/google.exporter.ts +1 -1
- package/src/transformers/google.transformer.ts +15 -1
package/package.json
CHANGED
|
@@ -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 (
|
|
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
|
|
|
@@ -323,7 +337,7 @@ export class GoogleTransformer {
|
|
|
323
337
|
let timestamp = +get(car, 'mainData.firstRegistration', '')
|
|
324
338
|
|
|
325
339
|
if (!timestamp) {
|
|
326
|
-
timestamp =
|
|
340
|
+
timestamp = Math.round(new Date().getTime() / 1000)
|
|
327
341
|
}
|
|
328
342
|
|
|
329
343
|
const date = new Date(timestamp * 1000);
|