8 |
use strip; |
use strip; |
9 |
|
|
10 |
my $reduce_count = qq| |
my $reduce_count = qq| |
11 |
function (Key, Values) { |
function (Key, Values) { |
12 |
var sum = 0; |
var sum = 0; |
13 |
for(var i in Values) |
for(var i in Values) |
14 |
sum += Values[i]; |
sum += Values[i]; |
15 |
return sum; |
return sum; |
16 |
} |
} |
17 |
|
|; |
18 |
|
|
19 |
|
my $reduce_join = qq| |
20 |
|
function (k, v, c) { |
21 |
|
if ( c ) { |
22 |
|
a = v.shift(); |
23 |
|
//log( a ); log( v ); |
24 |
|
while ( v.length ) { |
25 |
|
//log( v.length ); |
26 |
|
e = v.shift(); |
27 |
|
//log( e ); |
28 |
|
a.concat( e ); |
29 |
|
} |
30 |
|
return a; |
31 |
|
} else { |
32 |
|
return v; |
33 |
|
} |
34 |
|
} |
35 |
|; |
|; |
36 |
|
|
37 |
db 'reblog/', containing { |
db 'reblog/', containing { |
76 |
); |
); |
77 |
} |
} |
78 |
|), |
|), |
79 |
'reduce' => strip(qq| |
'reduce' => strip($reduce_join), |
80 |
function (k, v) { |
}, |
81 |
return v; |
'by_feed_html' => { |
82 |
|
'map' => strip(qq| |
83 |
|
function(doc) { |
84 |
|
emit( |
85 |
|
[ doc.feed_title, doc.feed_link ], |
86 |
|
'<a href="' + doc.link + '">' + doc.title + '</a>' |
87 |
|
); |
88 |
} |
} |
89 |
|), |
|), |
90 |
|
'reduce' => strip($reduce_join), |
91 |
}, |
}, |
92 |
'by_date' => { |
'by_date' => { |
93 |
'map' => strip(qq| |
'map' => strip(qq| |
94 |
function(doc) { |
function(doc) { |
95 |
emit( |
emit( |
96 |
[ doc.insert_timestamp, doc.feed_title, doc.feed_link ], |
[ doc.insert_timestamp, doc.feed_title, doc.feed_link ], |
97 |
[ doc.title, doc.link ] |
[ doc.title, doc.link ] |
98 |
); |
); |
99 |
} |
} |
100 |
|), |
|), |
101 |
} |
} |
102 |
}, |
}, |