changes in the flag unset (we consider both 0 and 1)
This commit is contained in:
1 parent
f21a572f45
commit
06649044ba
1 file changed
+12
-5
+12
-5
@@ -153,15 +153,22 @@ async function runConnector() {
|
||||
try {
|
||||
console.log('Retrieving data from Keystone...', lastRunDate, tomorrowDate, isDryRun );
|
||||
// getLeads(lastRunDate, currentDate, unsent, test)
|
||||
const unsetValue = 0;
|
||||
const firstUnsetValue = 1;
|
||||
const secondUnsetValue = 0;
|
||||
const testValue = isDryRun ? 1 : 0;
|
||||
const leads = await getLeads(lastRunDate, tomorrowDate, unsetValue, testValue);
|
||||
const newLeads = await getLeads(lastRunDate, tomorrowDate, firstUnsetValue, testValue);
|
||||
const oldLeads = await getLeads(lastRunDate, tomorrowDate, secondUnsetValue, testValue);
|
||||
|
||||
if (!leads.length) {
|
||||
const allLeads = [...newLeads, ...oldLeads].filter(
|
||||
(elem, index, self) => index === self.findIndex((el) => el.id === elem.id)
|
||||
); // questo evita duplicati basati sull'id
|
||||
//console.log(allLeads);
|
||||
|
||||
if (!allLeads.length) {
|
||||
console.log('No data retrieved.');
|
||||
return;
|
||||
}
|
||||
console.log('New leads:', leads.length);
|
||||
console.log('New leads:', allLeads.length);
|
||||
|
||||
// here we save the last time we ran the connector
|
||||
if (!isDryRun) {
|
||||
@@ -180,7 +187,7 @@ async function runConnector() {
|
||||
console.log('Connection successful!');
|
||||
|
||||
// leadsArray accepts either a single lead object or multiple leads(array)
|
||||
const leadsArray = Array.isArray(leads) ? leads : [leads];
|
||||
const leadsArray = Array.isArray(allLeads) ? allLeads : [allLeads];
|
||||
let allPayloads = (aggregateLeadsByEmail(leadsArray)).map(lead => mapFields(lead));
|
||||
|
||||
/*let nationalityOptions = '';
|
||||
|
||||
Reference in new issue
Block a user