Last active
August 29, 2015 14:15
-
-
Save liorkesos/898a9412975d1cabcaba to your computer and use it in GitHub Desktop.
function not working
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint latedef:false*/ | |
'use strict'; | |
var utils = require('./utils'), | |
_ = require('lodash'), | |
config = require('meanio').loadConfig(); | |
exports.clients = function(req,res){ | |
// get summary array for all clients. | |
var clientsConfig = config.togglaccounts; | |
var clients = {}; | |
_.forIn(clientsConfig,function(value, key) { | |
var tglo = utils.buildTgl(key); | |
var tgl = tglo.tgl; | |
var options = {tgl: tgl, key: key}; | |
getSummaryReport(options,function (err,data){ | |
console.log('ddd',data); | |
}); | |
console.log(clients); | |
}); | |
return(clients); | |
//res.send(clients); | |
function getSummaryReport( topts ){ | |
// console.log(tgl); | |
//console.log('-----'); | |
//console.log(account); | |
var tgl = topts.tgl; | |
var account = topts.key; | |
var options = { | |
workspace_id: config.togglaccounts[account].workspace, | |
user_agent: account + '_api' | |
}; | |
tgl.summaryReport(options, function (err, summaryData){ | |
if (err){ throw(err);} | |
var hrs = summaryData.total_grand / 3600000; // miliseconds to hrs. | |
var budget = parseInt(config.togglaccounts[account].budget); | |
var hro = { | |
hrs:hrs, | |
budget:budget, | |
progress: hrs/budget +'%' | |
}; | |
console.log('hhh', hro); | |
return hro; | |
}); | |
} | |
}; //end of exports.clients | |
exports.userData = function(req,res){ | |
var account = req.params.account; | |
var tgl = utils.buildTgl(account).tgl; | |
var options = {}; | |
tgl.getUserData(options, function(err, userData){ | |
res.send(userData); | |
}); | |
}; | |
/* | |
exports.summary = function(req,res) { | |
var account = req.params.account; | |
var tglo = utils.buildTgl(account); | |
var tgl = tglo.tgl; | |
console.log('before'); | |
// var config = tglo.config; | |
var hro = _getSummaryReport( tgl, account ); | |
res.send(hro); | |
}; | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
made public