bot-functions 1.6.0 → 1.7.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.
- package/index.js +33 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -905,6 +905,37 @@ const sendDataCH = async (params, dataJSON) => {
|
|
|
905
905
|
});
|
|
906
906
|
}
|
|
907
907
|
|
|
908
|
+
const sendDataClickHouse = async (params, dataJSON) => {
|
|
909
|
+
return new Promise(async function (resolve, reject) {
|
|
910
|
+
actualFunction = "sendDataClickHouse";
|
|
911
|
+
try {
|
|
912
|
+
payload = {
|
|
913
|
+
params,
|
|
914
|
+
data: dataJSON
|
|
915
|
+
}
|
|
916
|
+
const batchPromises = [];
|
|
917
|
+
const stringData = JSON.stringify(dataJSON);
|
|
918
|
+
const response = await axios({
|
|
919
|
+
method: 'post',
|
|
920
|
+
url: process.env.INSERT_CLICKHOUSE,
|
|
921
|
+
data: payload,
|
|
922
|
+
maxBodyLength: Infinity,
|
|
923
|
+
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json'}
|
|
924
|
+
});
|
|
925
|
+
batchPromises.push(response.status);
|
|
926
|
+
batchPromises.map(reg => log.info('Insert status', reg));
|
|
927
|
+
if (batchPromises.every(reg => reg == 200)) {
|
|
928
|
+
resolve({ status: "Packages inserted successfully", exit: 1 });
|
|
929
|
+
} else {
|
|
930
|
+
return reject(new Error('No se insertaron todos los paquetes'));
|
|
931
|
+
}
|
|
932
|
+
} catch (error) {
|
|
933
|
+
await insertLog(params, 107);
|
|
934
|
+
return reject(new Error(error.message));
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
908
939
|
const waitFrame = (page, frame, framename, info, timeout, parent = null) => {
|
|
909
940
|
return new Promise(async function (resolve, reject) {
|
|
910
941
|
let counter = 0;
|
|
@@ -1510,5 +1541,6 @@ module.exports = {
|
|
|
1510
1541
|
processDataDaily,
|
|
1511
1542
|
uploadImageToS3,
|
|
1512
1543
|
insertCatspecs,
|
|
1513
|
-
uploadEvidence
|
|
1544
|
+
uploadEvidence,
|
|
1545
|
+
sendDataClickHouse
|
|
1514
1546
|
}
|