pim-import 6.9.0 → 6.10.1
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AvailableCatalogs, PaginationResults } from "../../types";
|
|
2
|
-
export declare const importLatestProducts: (catalog: AvailableCatalogs, lastModified: string, page?: number,
|
|
2
|
+
export declare const importLatestProducts: (catalog: AvailableCatalogs, lastModified: string, page?: number, size?: number, lastModifiedTo?: string) => Promise<PaginationResults>;
|
|
@@ -5,16 +5,16 @@ const endpoints_1 = require("../endpoints");
|
|
|
5
5
|
const logs_1 = require("../../libs/logs");
|
|
6
6
|
const products_1 = require("./products");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
|
-
const importLatestProducts = async (catalog, lastModified, page = 0,
|
|
8
|
+
const importLatestProducts = async (catalog, lastModified, page = 0, size = 100, lastModifiedTo = "") => {
|
|
9
9
|
const timeStart = new Date();
|
|
10
10
|
page = Number(page);
|
|
11
|
-
|
|
12
|
-
(0, logs_1.log)(`importLatestProducts - catalog: ${catalog} lastModified: ${lastModified} page: ${page}
|
|
13
|
-
const data = await (0, endpoints_1.getLatestProducts)(catalog, lastModified, page,
|
|
11
|
+
size = Number(size);
|
|
12
|
+
(0, logs_1.log)(`importLatestProducts - catalog: ${catalog} lastModified: ${lastModified} page: ${page} size: ${size} lastModifiedTo: ${lastModifiedTo}`, "INFO");
|
|
13
|
+
const data = await (0, endpoints_1.getLatestProducts)(catalog, lastModified, page, size, lastModifiedTo);
|
|
14
14
|
const total = data.totalElements;
|
|
15
15
|
const products = data.content;
|
|
16
16
|
(0, logs_1.log)(`${total} products founded`);
|
|
17
|
-
let count = page *
|
|
17
|
+
let count = page * size + 1;
|
|
18
18
|
let current = 0;
|
|
19
19
|
for (const product of products) {
|
|
20
20
|
(0, logs_1.log)(`${count} of ${total}`);
|
|
@@ -30,11 +30,11 @@ const importLatestProducts = async (catalog, lastModified, page = 0, limit = 100
|
|
|
30
30
|
const timeEnd = new Date();
|
|
31
31
|
const seconds = (0, utils_1.secondBetweenTwoDate)(timeStart, timeEnd);
|
|
32
32
|
(0, logs_1.log)(`Request time: ${seconds} seconds`);
|
|
33
|
-
const
|
|
33
|
+
const nextPage = Number(page) + 1;
|
|
34
34
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
completed,
|
|
35
|
+
page: nextPage,
|
|
36
|
+
size,
|
|
37
|
+
completed: nextPage >= data.totalPages,
|
|
38
38
|
total,
|
|
39
39
|
totalPages: data.totalPages,
|
|
40
40
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PaginationResults } from "../../types";
|
|
2
|
-
export declare const importModels: (page?: number, size?: number) => Promise<PaginationResults>;
|
|
2
|
+
export declare const importModels: (page?: number, size?: number, singleModelCode?: string) => Promise<PaginationResults>;
|
|
@@ -139,19 +139,27 @@ const importModel = async (model) => {
|
|
|
139
139
|
}
|
|
140
140
|
return topicModel;
|
|
141
141
|
};
|
|
142
|
-
const importModels = async (page = 0, size = 40) => {
|
|
142
|
+
const importModels = async (page = 0, size = 40, singleModelCode) => {
|
|
143
143
|
(0, logs_1.log)(`importModels - page: ${page}, size: ${size}`, "INFO");
|
|
144
144
|
const models = await (0, endpoints_1.getOtherCatalogData)("models", page, size, true);
|
|
145
145
|
const total = models?.content?.length || 0;
|
|
146
|
+
let forceCompleted = false;
|
|
146
147
|
if (models?.content?.length) {
|
|
147
148
|
(0, logs_1.log)(`Founded ${total} models`);
|
|
148
149
|
let count = page * size;
|
|
149
150
|
let current = 0;
|
|
150
151
|
for (const model of models.content) {
|
|
152
|
+
if (singleModelCode && model.code !== singleModelCode) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
151
155
|
(0, logs_1.log)(`${++count} of ${models.totalElements}`);
|
|
152
156
|
const topicModel = await importModel(model);
|
|
153
157
|
await createOrUpdatePage(topicModel);
|
|
154
158
|
await updateComponentModelOfSubFamilyPages(topicModel);
|
|
159
|
+
if (singleModelCode && model.code === singleModelCode) {
|
|
160
|
+
forceCompleted = true;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
155
163
|
if (logs_1.serverUtils) {
|
|
156
164
|
logs_1.serverUtils.log(model.code);
|
|
157
165
|
const progress = Math.floor((++current / models.content.length) * 100);
|
|
@@ -169,7 +177,7 @@ const importModels = async (page = 0, size = 40) => {
|
|
|
169
177
|
return {
|
|
170
178
|
page: nextPage,
|
|
171
179
|
size: Number(size),
|
|
172
|
-
completed: nextPage >= models.totalPages,
|
|
180
|
+
completed: nextPage >= models.totalPages || forceCompleted,
|
|
173
181
|
total: models.totalElements,
|
|
174
182
|
totalPages: models.totalPages,
|
|
175
183
|
};
|
|
@@ -1556,7 +1556,9 @@ const generateTechSpecPdf = async (topicProductId, country = "global", locale =
|
|
|
1556
1556
|
const fileName = (pageSlug.length >= 170
|
|
1557
1557
|
? `tech-spec-${topicProductId}`
|
|
1558
1558
|
: `tech-spec-${pageSlug}`) + `_${country}-${locale}`;
|
|
1559
|
-
let baseUrl = process.env.
|
|
1559
|
+
let baseUrl = country === "cn" && process.env.FPI_TECH_SPEC_BASE_URL_CN
|
|
1560
|
+
? process.env.FPI_TECH_SPEC_BASE_URL_CN
|
|
1561
|
+
: (process.env.FPI_TECH_SPEC_BASE_URL ?? "");
|
|
1560
1562
|
if (!baseUrl) {
|
|
1561
1563
|
(0, logs_1.log)(`FPI_TECH_SPEC_BASE_URL process env not found`, "ERROR");
|
|
1562
1564
|
}
|