Permalink
Browse files

fixed view reduce overflow error

  • Loading branch information...
1 parent d1f17c3 commit c99df7dea3966743b07b55ebe5b45d59fd2c51c1 @dominictarr committed Jun 6, 2011
Showing with 49 additions and 12 deletions.
  1. +1 −0 .gitignore
  2. +17 −7 initialize.js
  3. +30 −5 test/couch.asynct.js
  4. +1 −0 test/data/testbed-notinstalled.json
View
@@ -3,3 +3,4 @@ node_modules/*
test/tmp/*
workspace
workspace/*
+public/javascripts/google-analytics.js
View
@@ -13,26 +13,27 @@ module.exports = function (opts,callback){
opts.cache = true
console.log("INIT VIEWS", opts)
return init(opts.name,opts)
- .view('all/status', function(doc) {
+/* .view('all/status', function(doc) {
var status = doc.report.tests
.map(function (e){
return {name: e.filename || e.name, status: e.status}
})
emit([doc.username,doc.project,doc.commit], status);
- })
+ })*/
.view('all/summary', function(doc) {
if(doc.type != 'repo' || !doc.report.tests)
return
try{
var total = 0, passes = 0
, status = doc.report.status
- doc.report.tests.map(function (e){
+
+ doc.report.tests.forEach(function (e){
total ++;
if(e.status == 'success') passes ++;
return e.status
- }).reduce(function (x,y){
+ })/*.reduce(function (x,y){
return x < y ? x : y
- })
+ })*/
var time = new Date(doc.time)
emit([doc.username,doc.project,time], {
commit: doc.commit,
@@ -47,6 +48,14 @@ module.exports = function (opts,callback){
}
}, function (key,values){
try {
+ if(key == 'error')
+ return {
+ commit: 'various',
+ status:'view errors',
+ time: new Date(),
+ total: values.length,
+ passes: 0
+ }
var max = null
values.forEach(function (e){
if(!max || new Date(e.time) > new Date(max.time))
@@ -57,11 +66,12 @@ module.exports = function (opts,callback){
return err
}
})
- .view('all/ordered', function(doc) {
+/* .view('all/ordered', function(doc) {
var status = doc.state.tests
.map(function (e){
return {name: e.filename || e.name, status: e.status}
})
emit([doc.username,doc.project,doc.time,doc.state.commit], status);
- }).ready(callback)
+ })*/
+ .ready(callback)
}
View
@@ -3,11 +3,13 @@ var db
, opts = {
name: 'test-testbed',
clobber: true,
- host: 'localhost',
+ host: 'testbedjs.org',
raw: true
}
, fs = require('fs')
, data = JSON.parse(fs.readFileSync(__dirname + '/data/testbed-migrated.json'))
+
+ data.push(JSON.parse(fs.readFileSync(__dirname + '/data/testbed-notinstalled.json')))
exports.__setup = function (test){
@@ -21,8 +23,8 @@ exports.__setup = function (test){
console.log(data)
db.save(data, function (err){
- if(err)
- throw error
+ //if(err)
+ //throw err
console.info("DATABASE '" + opts.name + "' IS READY")
test.done()
})
@@ -34,7 +36,7 @@ var summary =
name:it.ok()
, status:it.ok()
}))
-
+/*
exports ['test ordered'] = function (test){
db.view('all/ordered', function (err,data){
@@ -58,7 +60,7 @@ exports ['test ordered'] = function (test){
test.done()
})
}
-
+*/
exports ['test summary'] = function (test){
/*
@@ -82,3 +84,26 @@ exports ['test summary'] = function (test){
test.done()
})
}
+exports ['test summary goup_level=2'] = function (test){
+
+/*
+ show the results of the latest commit for each user's project
+
+*/
+
+ db.view('all/summary', {reduce: true, group_level: 2}, function (err,data){
+ if(err) throw err
+ console.log("all/summary:",data.rows)
+ var seen = []
+ it(data.rows).every(it.has({
+ key: it.property('length',it.ok())//username,project
+ , value: it.has({
+ commit: it.matches(/[\w|\d]+/)
+ , status: it.matches(/success|failure|error|install-error|notinstalled|invalid/)
+ , passes: it.typeof('number')
+ , total: it.typeof('number')
+ })
+ })).property('length', it.ok("length must be > 0"))
+ test.done()
+ })
+}
@@ -0,0 +1 @@
+{"_id":"Marak,webservice.js,1c8eb0d75d72483502f8160884d5dfec806b5d44","_rev":"3-4eb73a4babf874c733aa13fb5bd6ce0c","commit":"1c8eb0d75d72483502f8160884d5dfec806b5d44","installation":[],"package":{"name":"webservice","description":"turns modules into RESTFul web-services","version":"0.5.0","author":"Marak Squires <marak.squires@gmail.com>","repository":{"type":"git","url":"http://github.com/marak/webservice.js.git"},"keywords":["webservice","REST","web-service","JSON"],"main":"./lib/webservice","dependencies":{"journey":"= 0.4.0-pre","colors":">= 0.5.0"},"scripts":{"test":"vows","start":"server.js"},"engines":{"node":">= 0.4.0"}},"post":{"deleted":false,"pusher":{"email":"marak.squires@gmail.com","name":"Marak"},"compare":"https://github.com/Marak/webservice.js/compare/07fc920...1c8eb0d","ref":"refs/heads/master","commits":[{"timestamp":"2011-06-05T15:48:35-07:00","removed":["tests/test-client-generator.js","tests/test-webservice.js","tests/wsscreenshot.png"],"author":{"username":"Marak","email":"marak.squires@gmail.com","name":"Marak Squires"},"message":"Renamed \"tests\" folder to \"test\"","distinct":true,"modified":["ReadMe.md"],"url":"https://github.com/Marak/webservice.js/commit/1c8eb0d75d72483502f8160884d5dfec806b5d44","added":["test/test-client-generator.js","test/test-webservice.js","test/wsscreenshot.png"],"id":"1c8eb0d75d72483502f8160884d5dfec806b5d44"}],"before":"07fc9206ec45915c2c56ebb0ea3e384916b97c32","after":"1c8eb0d75d72483502f8160884d5dfec806b5d44","repository":{"language":"JavaScript","has_issues":true,"has_downloads":true,"homepage":"http://blog.nodejitsu.com/create-nodejs-web-services-in-one-line","pushed_at":"2011/06/05 15:47:52 -0700","fork":false,"description":" turn node.js modules into RESTFul web-services","url":"https://github.com/Marak/webservice.js","watchers":139,"private":false,"size":2316,"open_issues":5,"owner":{"email":"marak.squires@gmail.com","name":"Marak"},"name":"webservice.js","has_wiki":true,"created_at":"2010/09/18 05:38:07 -0700","forks":11},"forced":false,"created":false,"base_ref":null},"project":"webservice.js","report":{"status":"notinstalled","failures":[],"tests":[]},"state":{"init":true,"update":false,"tested":false},"time":"2011-06-05T22:49:31.097Z","type":"repo","username":"Marak"}

0 comments on commit c99df7d

Please sign in to comment.