Hi,

I'm trying to build a summary view for a pie chart based on a document count 
within date ranges as shown below. 

The map function is basically working, except I need to get the "emit(XX-Days, 
1);" part to write a variable label in the place of the XX-Days. e.g. 
30-Days,60-Days,90-Days. However, I can't seem to work out a way to do this. 

Any suggestions would be much appreciated.


Map Function:

function(doc){
    var now = new Date((new Date()).getTime());
    var thirty_days_from_now = new Date((new Date()).getTime() + 
30*24*60*60*1000);
    var sixty_days_from_now = new Date((new Date()).getTime() + 
60*24*60*60*1000);
    var ninty_days_from_now = new Date((new Date()).getTime() + 
90*24*60*60*1000);
    var expire = Date.parse(doc.date.expire)

    
    var exps = [thirty_days_from_now, sixty_days_from_now, ninty_days_from_now];

for (r in exps){
   if (expire >= now && expire <= (exps[r])){
   emit(XX-Days, 1);
     
   }
 }
return;
}

Reduce Function:

_count

Regards,

Carl

Reply via email to