Fixed Issue 122: item_frequencies doesn't work if tag is also the name of a native js function
Did this by checking if the item is a native function, if it is I set it to an initial numeric value. Future occurrences of the tag count correctly.
This commit is contained in:
parent
ce8b3ea0a1
commit
ba9813e5a3
@ -1209,11 +1209,19 @@ class QuerySet(object):
|
||||
db[collection].find(query).forEach(function(doc) {
|
||||
if (doc[field].constructor == Array) {
|
||||
doc[field].forEach(function(item) {
|
||||
frequencies[item] = inc + (frequencies[item] || 0);
|
||||
var preValue = 0;
|
||||
if (!isNaN(frequencies[item])) {
|
||||
preValue = frequencies[item];
|
||||
}
|
||||
frequencies[item] = inc + preValue;
|
||||
});
|
||||
} else {
|
||||
var item = doc[field];
|
||||
frequencies[item] = inc + (frequencies[item] || 0);
|
||||
var preValue = 0;
|
||||
if (!isNaN(frequencies[item])) {
|
||||
preValue = frequencies[item];
|
||||
}
|
||||
frequencies[item] = inc + preValue;
|
||||
}
|
||||
});
|
||||
return frequencies;
|
||||
|
Loading…
x
Reference in New Issue
Block a user