bot-functions 1.6.0 → 1.7.0

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.
Files changed (2) hide show
  1. package/index.js +26 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -905,6 +905,30 @@ 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
+ const batchPromises = [];
913
+ const stringData = JSON.stringify(dataJSON);
914
+ const response = await axios({
915
+ method: 'post', url: process.env.INSERT_CLICKHOUSE, data: {params, dataJSON: stringData },
916
+ maxBodyLength: Infinity, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }
917
+ });
918
+ batchPromises.push(response.status);
919
+ batchPromises.map(reg => log.info('Insert status', reg));
920
+ if (batchPromises.every(reg => reg == 200)) {
921
+ resolve({ status: "Packages inserted successfully", exit: 1 });
922
+ } else {
923
+ return reject(new Error('No se insertaron todos los paquetes'));
924
+ }
925
+ } catch (error) {
926
+ await insertLog(params, 107);
927
+ return reject(new Error(error.message));
928
+ }
929
+ });
930
+ }
931
+
908
932
  const waitFrame = (page, frame, framename, info, timeout, parent = null) => {
909
933
  return new Promise(async function (resolve, reject) {
910
934
  let counter = 0;
@@ -1510,5 +1534,6 @@ module.exports = {
1510
1534
  processDataDaily,
1511
1535
  uploadImageToS3,
1512
1536
  insertCatspecs,
1513
- uploadEvidence
1537
+ uploadEvidence,
1538
+ sendDataClickHouse
1514
1539
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bot-functions",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Bot functions",
5
5
  "main": "index.js",
6
6
  "scripts": {