Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
selector: function (searchObject, options, aggregation) {
let selector = this.defaultConfiguration().selector(searchObject, options, aggregation),
categoryFilter = options.search.props.categoryFilter;
if (_.isString(categoryFilter) && !_.isEmpty(categoryFilter)) {
selector.category = categoryFilter;
}
selector["meta.userId"] = options.search.userId;
// selector["$or"] = [{"title":"rework"}];
//
console.log(options.search.userId);
console.log(JSON.stringify(selector));
return selector;
}
}),
getUserStatistics = function(scope, userId, query) {
console.log(userId);
if (scope == "private") {
var uid = Meteor.userId();
} else if (scope == "public" || userId == Meteor.userId() || !scope ) {
var uid = userId;
}
console.log(userId);
query["meta.userId"] = uid;
var books = Books.find(query).fetch();
console.log(query);
pageCounts = [];
var bookCount = 0;
var booksWithMetadataCount = 0;
books.forEach(function (book) {
bookCount = bookCount + 1;
if(book.hasOwnProperty("publisherMetadata")){
if(book.publisherMetadata.hasOwnProperty("pageCount")){
pageCounts.push(book.publisherMetadata.pageCount);
booksWithMetadataCount = booksWithMetadataCount + 1;
}
}
});
let pagesRead = 0;
for (var i = pageCounts.length; i--;){
fetchBooks = function(search, sort, fields, user) {
console.log("fetch books function called");
var query = {};
if(typeof search === undefined || search === null){
query[0] = {"meta.userId":user};
} else {
console.log("search found:"+JSON.stringify(search));
var querySelector = search;
querySelector["meta.userId"] = user;
query[0] = querySelector
console.log("query[0] = " + JSON.stringify(query[0]))
}
if (typeof sort === undefined || sort === null) {
query[1] = {sort: { "meta.dateReadSort": -1} };
} else {
query[1] = sort;
}
if (typeof(fields) === undefined || fields === null) {
query[2] = {fields:{}};
} else if (fields) {
query[2] = fields;
} else {