Permalink
Browse files

refactoring... data is donormalized so the doc has venue cap, short n…

…ame, and volunteer numbers
  • Loading branch information...
1 parent 21dcb00 commit af7c4c0c1a192479be8ecadb6d56c81dd14d101b @cdcarter committed Jul 30, 2011
Showing with 18 additions and 19 deletions.
  1. +6 −0 shows/web-info.js
  2. +12 −19 vendor/showmath.js
View
@@ -7,6 +7,12 @@ function(doc,req) {
doc = calc.avg(doc);
doc.guess = calc.guess(doc);
+
+ if (doc.perfd==0) {
+ doc.perfd = "None";
+ doc.avg = "None";
+ doc.latest = "None";
+ }
doc.action = path.rewrite(doc._id)
doc.list = path.rewrite()
View
@@ -14,11 +14,7 @@ exports.init = function(ddoc) {
doc.shows[i].time = ddoc.data.slots[doc.shows[i].slot]
}
- if (doc.perfd == 0){
- doc.avg = "None"
- doc.latest = "None"
- doc.perfd = "None"
- } else {
+ if (doc.perfd !== 0){
doc.avg = doc.avg/doc.perfd
doc.latest = doc.shows[doc.perfd-1].count
}
@@ -29,26 +25,23 @@ exports.init = function(ddoc) {
function guess(doc) {
if(typeof doc.perfd === "undefined") {
doc = avg(doc)
- }
- var venue = _.detect(ddoc.data.venues["by-name"],function(v){return v.name==doc.venue})
- var counts = _.detect(ddoc.data.venues.counts,function(v){return v.short==venue.short})
-
- var needs = {"side":counts["side-min"],"box":counts["box-min"],"usher":counts["ush-min"]}
+ }
+ var needs = {"side":doc["side-min"],"box":doc["box-min"],"usher":doc["ush-min"]}
- if(doc.perfd === "None" ) {
+ if(doc.perfd === 0 ) {
return needs;
}
- if(doc.avg >= (venue.capacity*0.4)) {
- needs = addVol(needs,counts);
+ if(doc.avg >= (doc.capacity*0.4)) {
+ needs = addVol(needs,doc);
}
- if(doc.avg >= (venue.capacity*0.5)) {
- needs = addVol(needs,counts);
+ if(doc.avg >= (doc.capacity*0.5)) {
+ needs = addVol(needs,doc);
}
- if(doc.avg >= (venue.capacity*0.6)) {
- needs = addVol(needs,counts);
+ if(doc.avg >= (doc.capacity*0.6)) {
+ needs = addVol(needs,doc);
}
- if(doc.avg >= (venue.capacity*0.7)) {
- needs = addVol(needs,counts);
+ if(doc.avg >= (doc.capacity*0.7)) {
+ needs = addVol(needs,doc);
}
return needs;
}

0 comments on commit af7c4c0

Please sign in to comment.