Error logging, go back 2 years and 0 contact

handling
This commit is contained in:
Peter Morton 2023-06-25 17:56:53 -05:00
parent 51f68d5021
commit 4650a4d5a3

View File

@ -116,7 +116,7 @@ router.get("/", (req, res) => {
} }
}`; }`;
var startTime = new Date( var startTime = new Date(
new Date().setFullYear(new Date().getFullYear() - 1) new Date().setFullYear(new Date().getFullYear() - 2)
); );
var endTime = new Date(new Date().setHours(new Date().getHours() - 1)); var endTime = new Date(new Date().setHours(new Date().getHours() - 1));
@ -136,6 +136,17 @@ router.get("/", (req, res) => {
) )
.then((result) => { .then((result) => {
var contacts = result.data.data.findContactsCompletedBetween.edges; var 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) {
console.log("ERROR: Errors in results - " + error.message);
});
// TODO: Should keep errors for filteredContacts
result.data.errors = [];
}
var filteredContacts = []; var filteredContacts = [];
contacts.forEach(function (contact, i) { contacts.forEach(function (contact, i) {
if (contact.node.interaction.__typename === "Email") { if (contact.node.interaction.__typename === "Email") {
@ -162,6 +173,7 @@ router.get("/", (req, res) => {
summary.totalInboundCount = 0; summary.totalInboundCount = 0;
summary.totalInboundActiveSeconds = 0; summary.totalInboundActiveSeconds = 0;
if (summary.totalCount > 0) {
summary.firstContactReceivedDate = new Date( summary.firstContactReceivedDate = new Date(
filteredContacts[0].node.interaction.receivedDate filteredContacts[0].node.interaction.receivedDate
); );
@ -195,7 +207,7 @@ router.get("/", (req, res) => {
(summary.lastContactEndTime.getTime() - (summary.lastContactEndTime.getTime() -
summary.firstInboundContactStartDate.getTime()) / summary.firstInboundContactStartDate.getTime()) /
(1000 * 60); (1000 * 60);
}
result.data.data.summary = summary; result.data.data.summary = summary;
if (result.data) { if (result.data) {