Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
fixed view reduce overflow error
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictarr committed Jun 6, 2011
1 parent d1f17c3 commit c99df7d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ node_modules/*
test/tmp/*
workspace
workspace/*
public/javascripts/google-analytics.js
24 changes: 17 additions & 7 deletions initialize.js
Expand Up @@ -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,
Expand All @@ -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))
Expand All @@ -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)
}
35 changes: 30 additions & 5 deletions test/couch.asynct.js
Expand Up @@ -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){

Expand All @@ -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()
})
Expand All @@ -34,7 +36,7 @@ var summary =
name:it.ok()
, status:it.ok()
}))

/*
exports ['test ordered'] = function (test){
db.view('all/ordered', function (err,data){
Expand All @@ -58,7 +60,7 @@ exports ['test ordered'] = function (test){
test.done()
})
}

*/
exports ['test summary'] = function (test){

/*
Expand All @@ -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()
})
}
1 change: 1 addition & 0 deletions test/data/testbed-notinstalled.json
@@ -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.