I have a replication filter in JavaScript which is running too slowly, and it was suggested that I try re-writing it in erlang.
I've set up the environment, and am able to successfully execute simple erlang views in the futon "temp_view" dialog, but I'm not having any luck translating my JavaScript function to erlang.
Can anyone suggest how the following might best be re-written in erlang? Any help would be greatly appreciated.
function(doc, req) {
if (doc.date && doc.user_id && (doc.user_id == req.query.userid) && (doc._id.indexOf(\"_design\") != 0)){
var doc_month = "" + doc.date[1];
if(doc_month.length == 1) {
doc_month = "0" + doc_month;
}
var doc_day = "" + doc.date[2];
if(doc_day.length == 1) {
doc_day = "0" + doc_day;
}
var req_month = "" + req.query.month;
if(req_month.length == 1) {
req_month = "0" + req_month;
}
var req_day = "" + req.query.day;
if(req_day.length == 1) {
req_day = "0" + req_day;
}
var doc_datestring = doc.date[0] + "-" + doc_month + "-" + doc_day;
var req_datestring = req.query.year + "-" + req_month + "-" + req_day;
return (doc_datestring >= req_datestring);
} else {
return false;
}
}