Skip to content
Snippets Groups Projects
Commit 9491db19 authored by wactbprot's avatar wactbprot
Browse files

merge events

parent 4de5d4cc
No related branches found
No related tags found
No related merge requests found
function(head, req) {
var share = require("lib/share"),
data = {},
mergedEvents = [];
start(share.startJson);
while(row = getRow()) {
var rv = row.value,
signature = row.value.signature;
if(data[signature]){
data[signature].id.push(rv.id);
data[signature].sign.push(rv.sign);
}else{
data[signature] = {};
data[signature].id = [rv.id];
data[signature].sign = [rv.sign];
data[signature].title = rv.title;
data[signature].start = rv.start;
data[signature].end = rv.end;
}
}
for(var k in data){
mergedEvents.push(data[k]);
}
send(toJSON( mergedEvents));
}
\ No newline at end of file
...@@ -27,15 +27,19 @@ function(doc) { ...@@ -27,15 +27,19 @@ function(doc) {
dateObj.Value != ""){ dateObj.Value != ""){
var keyObj = dateObj.Value.split(" ")[0], var keyObj = dateObj.Value.split(" ")[0],
startDate = share.vlDateString(dateObj.Value), startDate = share.vlDateString(dateObj.Value).split(" ")[0],
valObj = { id : doc._id, valObj = { id : doc._id,
title : dc.Standard + ": " + customer + " " + dc.Sign, sign : dc.Sign,
title : dc.Standard + ": " + customer,
start : startDate start : startDate
}; };
if(dateObj.Duration){ if(dateObj.Duration){
valObj.end = share.addDays(dateObj.Duration, dateObj.Value); valObj.end = share.addDays(dateObj.Duration, dateObj.Value).split(" ")[0];
} }
emit(keyObj, valObj); valObj.signature = dc.Standard +"_"+
startDate + "_" + customer;
emit(keyObj, valObj);
} }
} //Date } //Date
} // Presettings } // Presettings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment