repo.or.cz
/
mygpo.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
move and split design docs
[mygpo.git]
/
couchdb
/
_design
/
listeners
/
views
/
by_podcast
/
reduce.js
blob
a834baac154df67d0b743b383491fb57e30ce5e7
1
function (keys, values, rereduce)
2
{
3
function unique(arr) {
4
var a = [];
5
var l = arr.length;
6
for(var i=0; i<l; i++) {
7
for(var j=i+1; j<l; j++) {
8
if (arr[i] === arr[j])
9
j = ++i;
10
}
11
a.push(arr[i]);
12
}
13
return a;
14
};
15
16
if (rereduce)
17
{
18
return sum(values)
19
}
20
{
21
/* We count one per user, not per play-event */
22
val = unique(values);
23
return val.length;
24
}
25
}