Added lint and format scripts

This commit is contained in:
2023-06-27 15:22:50 -05:00
parent 4650a4d5a3
commit 7df9f1e481
9 changed files with 3788 additions and 3041 deletions

View File

@@ -41,7 +41,7 @@ router.get("/", (req, res) => {
function query(referenceId) {
console.log("Executing Query");
var query = `query ($startTime: DateTime, $endTime: DateTime) {
const query = `query ($startTime: DateTime, $endTime: DateTime) {
findContactsCompletedBetween(startTime: $startTime, endTime: $endTime, filter: {interactionTypes : EMAIL}) {
totalCount
@@ -115,10 +115,10 @@ router.get("/", (req, res) => {
}
}
}`;
var startTime = new Date(
const startTime = new Date(
new Date().setFullYear(new Date().getFullYear() - 2)
);
var endTime = new Date(new Date().setHours(new Date().getHours() - 1));
const endTime = new Date(new Date().setHours(new Date().getHours() - 1));
axios
.post(
@@ -135,11 +135,11 @@ router.get("/", (req, res) => {
}
)
.then((result) => {
var contacts = result.data.data.findContactsCompletedBetween.edges;
const contacts = result.data.data.findContactsCompletedBetween.edges;
// Log error to console
if (result.data.errors && result.data.errors.length > 0) {
result.data.errors.forEach(function (error, i) {
result.data.errors.forEach(function (error) {
console.log("ERROR: Errors in results - " + error.message);
});
@@ -147,8 +147,8 @@ router.get("/", (req, res) => {
result.data.errors = [];
}
var filteredContacts = [];
contacts.forEach(function (contact, i) {
const filteredContacts = [];
contacts.forEach(function (contact) {
if (contact.node.interaction.__typename === "Email") {
// threadId if Reference in Subject line will do
if (
@@ -167,7 +167,7 @@ router.get("/", (req, res) => {
filteredContacts.length;
// Summary Values
var summary = {};
const summary = {};
summary.totalCount = filteredContacts.length;
summary.totalInboundCount = 0;
@@ -178,7 +178,7 @@ router.get("/", (req, res) => {
filteredContacts[0].node.interaction.receivedDate
);
filteredContacts.forEach(function (contact, i) {
filteredContacts.forEach(function (contact) {
if (contact.node.direction === "INBOUND") {
summary.totalInboundCount++;
if (!summary.firstInboundContactStartDate) {