@bytebrand/export-cars 1.22.22 → 1.22.23
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
|
@@ -215,7 +215,7 @@ export class GoogleTransformer {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
private getVehicleMsrp(car: DataSchemes.Car): string | undefined {
|
|
218
|
-
const retailPrice = get(car, '
|
|
218
|
+
const retailPrice = get(car, 'price.recomendedRetailPrice');
|
|
219
219
|
const salesPrice = get(car, 'price.currentSalesPrice', 0);
|
|
220
220
|
if (!retailPrice || round(retailPrice, 2) === round(salesPrice, 2)) {
|
|
221
221
|
return undefined;
|
|
@@ -540,12 +540,19 @@ export class GoogleTransformer {
|
|
|
540
540
|
return !mileage ? 10 : mileage;
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
private getYear(car: DataSchemes.Car) {
|
|
544
|
-
// mainData.firstModelsProductionDate
|
|
545
|
-
//
|
|
543
|
+
private getYear(car: DataSchemes.Car): number {
|
|
544
|
+
// mainData.firstModelsProductionDate/constructionYear are already 4-digit years
|
|
545
|
+
// (mobile.de "vintage"); firstRegistration/metaData.creationDate are unix timestamps
|
|
546
|
+
// in seconds. Not every car has firstModelsProductionDate (e.g. dealer FTP imports),
|
|
547
|
+
// so fall through to other date sources — `year` is a mandatory Google feed field.
|
|
546
548
|
const firstModelsProductionYear = toSafeInteger(get(car, 'mainData.firstModelsProductionDate', 0));
|
|
549
|
+
const constructionYear = toSafeInteger(get(car, 'mainData.constructionYear', 0));
|
|
550
|
+
const firstRegistrationYear = toSafeInteger(moment(+get(car, 'mainData.firstRegistration', 0) * 1000).format('YYYY'));
|
|
551
|
+
const metaCreationYear = toSafeInteger(moment(+get(car, 'metaData.creationDate', 0) * 1000).format('YYYY'));
|
|
552
|
+
const currentYear = toSafeInteger(moment().format('YYYY'));
|
|
547
553
|
|
|
548
|
-
return firstModelsProductionYear
|
|
554
|
+
return [firstModelsProductionYear, constructionYear, firstRegistrationYear, metaCreationYear, currentYear]
|
|
555
|
+
.find(year => year > TIMESTAMP_FIRST_YEAR);
|
|
549
556
|
}
|
|
550
557
|
|
|
551
558
|
private getDateFirstRegistered(car: DataSchemes.Car): string {
|