in amplify/backend/function/ConnectDialerJS/src/index.js [180:220]
async function queryDDB(){
// Now Datetime
var now = new Date();
var nowseconds = Math.round(now.getTime() / 1000);
//var nowisostring = now.toISOString();
var lastSuccessThreshold = nowseconds - (minbs * 60);
//console.log(`lastSuccessThreshold: ${lastSuccessThreshold}`);
var lastAttemptThreshold = nowseconds - (minbc * 60);
//console.log(`lastAttemptThreshold: ${lastAttemptThreshold}`);
// DynamoDB parameters
let params = {
TableName: storageContactsStoreName,
IndexName:'Enabled-lastSuccess',
KeyConditionExpression: 'enabled = :enabled and lastSuccess < :lst',
FilterExpression: 'lastAttempt < :lat and contactAttempts < :ma',
ExpressionAttributeValues: {
':enabled': "1",
':lst': lastSuccessThreshold,
':lat': lastAttemptThreshold,
':ma': ma
}
};
console.log(`queryDDB params: ${JSON.stringify(params)}`);
try {
var result = await docClient.query(params).promise();
} catch (error) {
console.error(JSON.stringify(error));
return {"Count": -1};
}
console.log(`queryDDB result: ${JSON.stringify(result)}`);
if (result['Count'] > 0){
return result;
} else {
return {"Count": 0};
}
}