@bytebrand/export-cars 1.21.55 → 1.21.57
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/services/images.service.d.ts +1 -0
- package/dist/services/images.service.js +11 -4
- package/dist/services/images.service.js.map +1 -1
- package/dist/transformers/google.transformer.d.ts +1 -0
- package/dist/transformers/google.transformer.js +10 -4
- package/dist/transformers/google.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/services/images.service.ts +13 -4
- package/src/transformers/google.transformer.ts +11 -5
package/package.json
CHANGED
|
@@ -96,23 +96,26 @@ export class ImagesService {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
async getExtIntDefaultImages(car: DataSchemes.Car, images: ImboImageResponseInterface[], imageType: ImageType, ignoreDefImages: boolean): Promise<{
|
|
99
|
+
extMain: any[];
|
|
99
100
|
ext: any[];
|
|
100
101
|
int: any[];
|
|
101
102
|
feat: any[];
|
|
102
103
|
}> {
|
|
103
104
|
if (!isNotEmptyArray(images)) {
|
|
104
|
-
return { ext: [], int: [], feat: [] };
|
|
105
|
+
return { extMain: [], ext: [], int: [], feat: [] };
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
const categorizedImages = this.categorizeImages(images);
|
|
108
109
|
|
|
109
110
|
const sortedImages = {
|
|
111
|
+
extMain: this.sortImages(categorizedImages.extMain),
|
|
110
112
|
ext: this.sortImages(categorizedImages.ext),
|
|
111
113
|
int: this.sortImages(categorizedImages.int),
|
|
112
114
|
feat: this.sortImages(categorizedImages.feat),
|
|
113
115
|
};
|
|
114
116
|
|
|
115
117
|
const transformedImages = {
|
|
118
|
+
extMain: this.generateImageLinks(sortedImages.extMain, car._id),
|
|
116
119
|
ext: this.generateImageLinks(sortedImages.ext, car._id),
|
|
117
120
|
int: this.generateImageLinks(sortedImages.int, car._id),
|
|
118
121
|
feat: this.generateImageLinks(sortedImages.feat, car._id),
|
|
@@ -122,22 +125,28 @@ export class ImagesService {
|
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
private categorizeImages(images: ImboImageResponseInterface[]): {
|
|
128
|
+
extMain: ImboImageResponseInterface[];
|
|
125
129
|
ext: ImboImageResponseInterface[];
|
|
126
130
|
int: ImboImageResponseInterface[];
|
|
127
131
|
feat: ImboImageResponseInterface[];
|
|
128
132
|
} {
|
|
129
133
|
const categorizedImages = {
|
|
134
|
+
extMain: [] as ImboImageResponseInterface[],
|
|
130
135
|
ext: [] as ImboImageResponseInterface[],
|
|
131
136
|
int: [] as ImboImageResponseInterface[],
|
|
132
137
|
feat: [] as ImboImageResponseInterface[],
|
|
133
138
|
};
|
|
134
139
|
|
|
135
140
|
images.forEach((image) => {
|
|
136
|
-
|
|
141
|
+
const { imageCodePredicted } = image;
|
|
142
|
+
|
|
143
|
+
if (/(_feat_|^conext)/.test(imageCodePredicted)) {
|
|
137
144
|
categorizedImages.feat.push(image);
|
|
138
|
-
} else if (/^
|
|
145
|
+
} else if (/^ext_f_(right|left|main)/.test(imageCodePredicted)) {
|
|
146
|
+
categorizedImages.extMain.push(image);
|
|
147
|
+
} else if (/^ext_[frlb]/.test(imageCodePredicted)) {
|
|
139
148
|
categorizedImages.ext.push(image);
|
|
140
|
-
} else if (/^int_[frlb]/.test(
|
|
149
|
+
} else if (/^int_[frlb]/.test(imageCodePredicted)) {
|
|
141
150
|
categorizedImages.int.push(image);
|
|
142
151
|
}
|
|
143
152
|
});
|
|
@@ -38,8 +38,10 @@ export class GoogleTransformer {
|
|
|
38
38
|
false,
|
|
39
39
|
);
|
|
40
40
|
|
|
41
|
-
if (!transformedImages.
|
|
41
|
+
if (!transformedImages.extMain.length) {
|
|
42
|
+
console.log(`Car ${car._id} has no extMain image`);
|
|
42
43
|
return null
|
|
44
|
+
}
|
|
43
45
|
|
|
44
46
|
const allImages = [
|
|
45
47
|
...transformedImages.ext,
|
|
@@ -47,8 +49,6 @@ export class GoogleTransformer {
|
|
|
47
49
|
...transformedImages.feat
|
|
48
50
|
]
|
|
49
51
|
|
|
50
|
-
console.log(car._id, transformedImages);
|
|
51
|
-
|
|
52
52
|
return {
|
|
53
53
|
google_product_category: '916',
|
|
54
54
|
vehicle_fulfillment: {
|
|
@@ -76,7 +76,7 @@ export class GoogleTransformer {
|
|
|
76
76
|
model: this.transformService.model(car),
|
|
77
77
|
trim: this.getTrim(car),
|
|
78
78
|
year: this.getYear(car),
|
|
79
|
-
mileage: `${this.
|
|
79
|
+
mileage: `${this.mileage(car)}km`,
|
|
80
80
|
color: this.getColor(car),
|
|
81
81
|
vehicle_option: this.getExtrasField(car),
|
|
82
82
|
body_style: this.mapBodyStyle(car),
|
|
@@ -214,7 +214,8 @@ export class GoogleTransformer {
|
|
|
214
214
|
selector_unknown: 'default',
|
|
215
215
|
};
|
|
216
216
|
const energyClass = get(car, 'environmentEmissions.energyEfficiencyClass', 'selector_unknown');
|
|
217
|
-
|
|
217
|
+
const value = get(available, energyClass);
|
|
218
|
+
return value.replace('+', '');
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
private getInstallment(car: DataSchemes.Car) {
|
|
@@ -345,6 +346,11 @@ export class GoogleTransformer {
|
|
|
345
346
|
return truncate(trim, { length: GOOGLE_MAX_TRIM_LENGTH, separator: ' ' });
|
|
346
347
|
}
|
|
347
348
|
|
|
349
|
+
mileage(car: DataSchemes.Car): number {
|
|
350
|
+
const mileage = get(car, 'mainData.mileage', 0);
|
|
351
|
+
return !mileage ? 10 : mileage;
|
|
352
|
+
}
|
|
353
|
+
|
|
348
354
|
private getYear(car: DataSchemes.Car) {
|
|
349
355
|
const firstModelsProductionDate = +get(car, 'mainData.firstModelsProductionDate', 0);
|
|
350
356
|
|