Skip to content

Instantly share code, notes, and snippets.

@mandric
Created September 29, 2011 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mandric/1251252 to your computer and use it in GitHub Desktop.
Save mandric/1251252 to your computer and use it in GitHub Desktop.
exports['clinic totals'] = function(test) {
var args = { group_level: 1 };
var sum = function(data) {
var t = 0;
for (var i in data.rows) {
t += data.rows[i].value;
}
return t;
};
db.getView('total_clinics_by_clinic', args, function (err, data) {
var total1 = sum(data);
db.getView('total_clinics_by_district_hospital', args, function (err, data) {
var total2 = sum(data);
test.same(total1, total2);
db.getView('total_clinics_by_health_center', args, function (err, data) {
var total3 = sum(data);
test.same(total2, total3);
test.done();
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment