This commit is contained in:
Wade Wegner 2016-08-07 18:30:16 -05:00
Родитель 6ef0fcbed2
Коммит f7fc5f374e
3 изменённых файлов: 13 добавлений и 13 удалений

Просмотреть файл

@ -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();
});
}); });
}); });
}); });