@bytebrand/export-cars 1.21.13 → 1.21.14

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.13",
3
+ "version": "1.21.14",
4
4
  "description": "",
5
5
  "author": "bytebrand",
6
6
  "license": "UNLICENSED",
@@ -22,32 +22,42 @@ export class SantanderExporter implements Exporter {
22
22
 
23
23
  async export(): Promise<void> {
24
24
  const [fileCSV] = this.configService.config.outputFiles;
25
- await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
26
- await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
25
+ const { localConvertedDirectory } = this.configService.config.pathesConfig;
26
+
27
+ await CronicleUtils.ensureDir(localConvertedDirectory);
28
+ await CronicleUtils.emptyDir(localConvertedDirectory);
27
29
 
28
30
  const santanderCSVBuilder = new SantanderCSVBuilder(fileCSV);
29
31
 
30
32
  const santanderTransformer = await this.moduleRef.create(SantanderTransformer);
31
33
 
34
+ const transformedCars = []
35
+
32
36
  await this.loaderService.process(async (chunk: FsChunkInterface) => {
33
37
  chunk.data = chunk.data.filter(e => this.carService.filterCar(e, this.rulesService.rules));
34
38
 
35
39
  if (chunk && chunk.data) {
36
- for (let i = 0; i < chunk.data.length; i += 1) {
37
- const data = chunk.data[i];
40
+ for (const data of chunk.data) {
38
41
  const { car, images } = data;
39
42
  const transformedData = await santanderTransformer.transform(car, images);
40
43
 
41
- const transformedNormalizedData = await santanderTransformer.normalizeCarData(transformedData)
44
+ if (chunk.data.indexOf(data) < 2) {
45
+ console.log(transformedData);
46
+ }
42
47
 
43
- await santanderCSVBuilder.addItem(transformedNormalizedData);
44
- this.carService.counter.countCar(data.images);
48
+ transformedCars.push(transformedData);
49
+ this.carService.counter.countCar(images);
45
50
  }
46
51
  }
47
52
  });
48
53
 
49
- console.log(this.carService.counter.getCountedCars());
54
+ const transformedNormalizedData = await santanderTransformer.normalizeCarData(transformedCars);
50
55
 
56
+ for (const data of transformedNormalizedData) {
57
+ await santanderCSVBuilder.addItem(data);
58
+ }
59
+
60
+ console.log(this.carService.counter.getCountedCars());
51
61
  await santanderCSVBuilder.buildEnd();
52
62
  }
53
63
  }
@@ -27,7 +27,7 @@ export class SantanderTransformer extends MobileTransformer {
27
27
  super(mappingService, userService, configService, imagesService);
28
28
  }
29
29
 
30
- async normalizeCarData(transformedCarData: unknown): Promise<unknown> {
30
+ async normalizeCarData(transformedCarData: unknown) {
31
31
  const data = transformedCarData as Array<{ [key: string]: any }>;
32
32
 
33
33
  const allKeys = new Set<string>();