Remove json2csv

This commit is contained in:
Christopher Cookman 2024-06-11 15:14:26 -06:00
parent 4e1fc89560
commit 5bdb2aae38
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
3 changed files with 12 additions and 23 deletions

View file

@ -6,7 +6,6 @@ const embeds = require("./embeds.json")
const axios = require('axios');
const ping = require("ping")
var commandsBase = require("./commands.json")
const json2csv = require("json2csv");
const ssh2 = require('ssh2')
const sshConn = new ssh2.Client();
// find first file in .ssh local to the script
@ -46,6 +45,15 @@ const mariadb = require('mariadb');
const pool = mariadb.createPool(config.mariadb);
const cdrPool = mariadb.createPool(config.cdrdb);
const json2csv = (obj) => {
let csv = "";
for (let key in obj) {
csv += `${key},${obj[key]}\n`;
}
return csv;
}
// Some functions for FreePBX
@ -1324,7 +1332,9 @@ dcClient.on('interactionCreate', async interaction => {
} else {
// Generate the CSV
const fields = ["calldate", "src", "dst", "duration", "disposition", "recordingfile"];
const csv = json2csv.parse(result);
// put fields at the top of the csv
result.unshift(fields);
const csv = json2csv(result);
const buffer = Buffer.from(csv, 'utf-8');
const attachment = new MessageAttachment(buffer, 'cdr.csv');
interaction.editReply({

20
package-lock.json generated
View file

@ -13,7 +13,6 @@
"colors": "^1.4.0",
"discord.js": "^14.7.1",
"freepbx-graphql-client": "^0.1.1",
"json2csv": "github:juanjoDiaz/json2csv",
"mariadb": "^3.2.0",
"ping": "^0.4.4",
"sqlite3": "^5.1.4",
@ -829,25 +828,6 @@
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"optional": true
},
"node_modules/json2csv": {
"version": "7.0.6",
"resolved": "git+ssh://git@github.com/juanjoDiaz/json2csv.git#8c7895c11321410968893519fe86a60d98269ed0",
"license": "MIT",
"workspaces": [
"packages/cli",
"packages/formatters",
"packages/node",
"packages/plainjs",
"packages/test-helpers",
"packages/transforms",
"packages/whatwg",
"packages/test-performance"
],
"engines": {
"node": ">=14.17.0",
"npm": ">=7.0.0"
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",

View file

@ -13,7 +13,6 @@
"colors": "^1.4.0",
"discord.js": "^14.7.1",
"freepbx-graphql-client": "^0.1.1",
"json2csv": "github:juanjoDiaz/json2csv",
"mariadb": "^3.2.0",
"ping": "^0.4.4",
"sqlite3": "^5.1.4",