Пример #1
0
    map: function(doc) {
        if(doc.type === 'item') {
            var util = require('views/lib/util');

            emit(doc.created_at, {
                doc: doc,
                domain: util.getDomain(doc.url),
                points: util.getPoints(doc.voted),
                numcomments: util.getNumComments(doc.comments) 
            });
        }
    }
Пример #2
0
    map: function(doc) {
        if(doc.type === 'item') {
            var util = require('views/lib/util');

            var points = util.getPoints(doc.voted);
            var score = util.findScore(points, doc.created_at);

            var numcomments = util.getNumComments(doc.comments);

            emit(score, {
                doc: doc,
                domain: util.getDomain(doc.url),
                points: points,
                numcomments: numcomments
            });
        }
    }
Пример #3
0
    map: function(doc) {
        if(doc.type === 'item') {
            var util = require('views/lib/util');
            
            var domain = util.getDomain(doc.url);
            var points = util.getPoints(doc.voted);
            var numcomments = util.getNumComments(doc.comments);

            for(var i in doc.voted) {
                emit([doc.voted[i], doc.created_at], {
                    doc: doc,
                    domain: domain,
                    points: points,
                    numcomments: numcomments 
                });
            }

        }
    }
Пример #4
0
    map: function(doc) {
        if(doc.type === 'item') {
            var util = require('views/lib/util');

            var points = util.getPoints(doc.voted);
            var score = util.findScore(points, doc.created_at);

            var numcomments = util.getNumComments(doc.comments);

            var comments = [];
            for(var i in doc.comments) {
                var c = doc.comments[i];
                var comment = {};

                // copy elements of comments since we
                // can't modify the object itself
                for(var x in c) {
                    comment[x] = c[x];
                }

                comment.points = util.getPoints(c.voted);
                comment.score = util.findScore(comment.points, c.comment_id);
                comment.text = util.formatdoc(comment.text);

                comments.push(comment);
            }

            emit(doc._id, {
                doc: doc,
                domain: util.getDomain(doc.url),
                points: points,
                numcomments: numcomments,
                comments: comments
            });
        }
    }