@bytebrand/export-cars 1.22.23 → 1.22.25
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
|
@@ -8,7 +8,6 @@ import { Injectable } from '@nestjs/common';
|
|
|
8
8
|
import { ConfigService, ImagesService, TransformerService, UserService } from '../services';
|
|
9
9
|
import { GoogleXmlItem } from '../interfaces';
|
|
10
10
|
import { isValidVin } from '../utils';
|
|
11
|
-
import moment from 'moment';
|
|
12
11
|
|
|
13
12
|
const GOOGLE_MAX_TRIM_LENGTH = 50;
|
|
14
13
|
const TIMESTAMP_FIRST_YEAR = 1970;
|
|
@@ -541,15 +540,17 @@ export class GoogleTransformer {
|
|
|
541
540
|
}
|
|
542
541
|
|
|
543
542
|
private getYear(car: DataSchemes.Car): number {
|
|
544
|
-
// mainData.firstModelsProductionDate
|
|
545
|
-
//
|
|
546
|
-
//
|
|
547
|
-
//
|
|
543
|
+
// mainData.firstModelsProductionDate is already a 4-digit year (mobile.de "vintage").
|
|
544
|
+
// constructionYear/firstRegistration/metaData.creationDate are unix timestamps in
|
|
545
|
+
// seconds (constructionYear is stored via legacy dateToUnix, not a bare year — see
|
|
546
|
+
// services/scrapper/src/ai/car-bridge.ts:174). Not every car has firstModelsProductionDate
|
|
547
|
+
// (e.g. dealer FTP imports), so fall through to other date sources — `year` is a
|
|
548
|
+
// mandatory Google feed field.
|
|
548
549
|
const firstModelsProductionYear = toSafeInteger(get(car, 'mainData.firstModelsProductionDate', 0));
|
|
549
|
-
const constructionYear =
|
|
550
|
-
const firstRegistrationYear =
|
|
551
|
-
const metaCreationYear =
|
|
552
|
-
const currentYear =
|
|
550
|
+
const constructionYear = new Date(+get(car, 'mainData.constructionYear', 0) * 1000).getUTCFullYear();
|
|
551
|
+
const firstRegistrationYear = new Date(+get(car, 'mainData.firstRegistration', 0) * 1000).getUTCFullYear();
|
|
552
|
+
const metaCreationYear = new Date(+get(car, 'metaData.creationDate', 0) * 1000).getUTCFullYear();
|
|
553
|
+
const currentYear = new Date().getUTCFullYear();
|
|
553
554
|
|
|
554
555
|
return [firstModelsProductionYear, constructionYear, firstRegistrationYear, metaCreationYear, currentYear]
|
|
555
556
|
.find(year => year > TIMESTAMP_FIRST_YEAR);
|