In Ox.api, allow for sums of text fields (= number of unique values, for example: number of artists in a list of works)
This commit is contained in:
parent
33db20f91c
commit
293c96a97d
1 changed files with 9 additions and 4 deletions
|
@ -214,7 +214,9 @@ Ox.api = function(items, options) {
|
|||
}*/
|
||||
});
|
||||
if (options.keys || options.positions) {
|
||||
result.data.items = sortBy(result.data.items, options.sort, map, options.query);
|
||||
result.data.items = sortBy(
|
||||
result.data.items, options.sort, map, options.query
|
||||
);
|
||||
}
|
||||
}
|
||||
if (options.positions) {
|
||||
|
@ -230,10 +232,13 @@ Ox.api = function(items, options) {
|
|||
// return totals
|
||||
data = {};
|
||||
api.sums.forEach(function(key) {
|
||||
data[key] = Ox.sum(result.data.items.map(function(item) {
|
||||
data[key] = result.data.items.map(function(item) {
|
||||
return item[key];
|
||||
}));
|
||||
})
|
||||
});
|
||||
data[key] = Ox.isString(data[key][0])
|
||||
? Ox.unique(data[key]).length
|
||||
: Ox.sum(data[key]);
|
||||
});
|
||||
data.items = result.data.items.length;
|
||||
if (api.geo) {
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue