diff options
author | Jan Lehnardt <jan@apache.org> | 2009-02-22 13:50:38 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-02-22 13:50:38 +0000 |
commit | 598eee1cf5979b61171f623da7e3164244ca3792 (patch) | |
tree | c9ff009fe39f2f07b060ace1149a8f074040c2a6 /share/www/script/couch.js | |
parent | 1ebc2117452516f6ac6f4f458d7372bc710b79d2 (diff) |
Add runtime statistics -- without EUnit tests for now.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@746691 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/couch.js')
-rw-r--r-- | share/www/script/couch.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js index 3f4db334..7bec5e32 100644 --- a/share/www/script/couch.js +++ b/share/www/script/couch.js @@ -312,6 +312,23 @@ CouchDB.request = function(method, uri, options) { return req; } +CouchDB.requestStats = function(module, key, aggregate, options) { + var options, optionsOrLast = Array.prototype.pop.apply(arguments); + if (typeof optionsOrLast == "string") { + options = null; + Array.prototype.push.apply(arguments, [optionsOrLast]); + } else { + options = optionsOrLast; + } + + var request_options = {}; + request_options.headers = {"Content-Type": "application/json"}; + + var stat = CouchDB.request("GET", "/_stats/" + Array.prototype.join.apply(arguments,["/"]) + (options ? + ("?" + CouchDB.params(options)) : ""), request_options).responseText; + return JSON.parse(stat)[module][key]; +} + CouchDB.uuids_cache = []; CouchDB.newUuids = function(n) { @@ -344,3 +361,13 @@ CouchDB.maybeThrowError = function(req) { throw result; } } + +CouchDB.params = function(options) { + options = options || {}; + var returnArray = []; + for(var key in options) { + var value = options[key]; + returnArray.push(key + "=" + value); + } + return returnArray.join("&"); +}
\ No newline at end of file |