updated
This commit is contained in:
Родитель
6ef0fcbed2
Коммит
f7fc5f374e
|
@ -34,7 +34,10 @@ module.exports = {
|
||||||
// last 6 hours; 60 minutes
|
// last 6 hours; 60 minutes
|
||||||
var since = new Date(now - 360 * 60000).toISOString();
|
var since = new Date(now - 360 * 60000).toISOString();
|
||||||
|
|
||||||
|
console.log('getCurrentBac: ' + userName);
|
||||||
|
|
||||||
postgres.get_recentCheckins(userName, since, function(recentCheckins) {
|
postgres.get_recentCheckins(userName, since, function(recentCheckins) {
|
||||||
|
|
||||||
var earliestDrinkAt = new Date(recentCheckins.rows[0].consumed_at__c);
|
var earliestDrinkAt = new Date(recentCheckins.rows[0].consumed_at__c);
|
||||||
var totalTimeInHours = Math.abs(now - earliestDrinkAt) / 36e5;
|
var totalTimeInHours = Math.abs(now - earliestDrinkAt) / 36e5;
|
||||||
|
|
||||||
|
|
|
@ -106,11 +106,7 @@ module.exports = function(app) {
|
||||||
var trigger = require('./apis/trigger');
|
var trigger = require('./apis/trigger');
|
||||||
|
|
||||||
trigger.insertNewCheckins(function(result) {
|
trigger.insertNewCheckins(function(result) {
|
||||||
console.log('test1');
|
|
||||||
console.log(result);
|
|
||||||
trigger.processNewCheckins(function(result2) {
|
trigger.processNewCheckins(function(result2) {
|
||||||
console.log('test2');
|
|
||||||
console.log(result2);
|
|
||||||
response.send('ok');
|
response.send('ok');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -177,7 +173,7 @@ module.exports = function(app) {
|
||||||
|
|
||||||
if (body.toLowerCase().indexOf('cool') !== -1)
|
if (body.toLowerCase().indexOf('cool') !== -1)
|
||||||
{
|
{
|
||||||
message = 'To get your current BAC, send "bac". To add a drink w/o Untapped send "new {oz} {abv}". To change # of oz, send "last {oz}". To understand the impact of a beer, send "impact {oz} {ab}".';
|
message = 'To get your current BAC, send "bac". To add a drink w/o Untapped send "new {oz} {abv}". To change # of oz, send "last {oz}". To understand the impact of a beer, send "impact {oz} {abv}".';
|
||||||
twiml.message(message);
|
twiml.message(message);
|
||||||
response.send(twiml);
|
response.send(twiml);
|
||||||
|
|
||||||
|
|
|
@ -13,18 +13,19 @@ describe('Trigger', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('New Checkins', function() {
|
describe('New Checkins', function() {
|
||||||
// it('should check for new checkins and insert into database', function(done) {
|
it('should check for new checkins and insert into database', function(done) {
|
||||||
|
|
||||||
// trigger.insertNewCheckins(function(results) {
|
trigger.insertNewCheckins(function(results) {
|
||||||
// console.log('back');
|
done();
|
||||||
// done();
|
});
|
||||||
// });
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
it('should process new checkins and send updated BAC values', function(done) {
|
it('should process new checkins and send updated BAC values', function(done) {
|
||||||
|
|
||||||
trigger.processNewCheckins(function(results) {
|
trigger.insertNewCheckins(function(results) {
|
||||||
done();
|
trigger.processNewCheckins(function(results2) {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче