Skip to content

Commit

Permalink
Refactoring frontend js
Browse files Browse the repository at this point in the history
  • Loading branch information
Mircea Danila Dumitrescu committed May 19, 2014
1 parent e25265a commit f3f6feb
Show file tree
Hide file tree
Showing 3 changed files with 593 additions and 722 deletions.
4 changes: 2 additions & 2 deletions bin/generator-config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions lib/analytics/genericGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
var myutils = require("./myutils.js"),
mongodb = require("mongodb"),
type_re = /^[a-z][a-zA-Z0-9_]+$/,
MAX_RETURNED_RECORDS = 10000;
MAX_RETURNED_RECORDS = 10000,
util = require("util");
function customQuery(collectionObj, filter, sort, limit, batchSize, streamified, documentHandler) {
// set MongoDB cursor options
var cursorOptions = {},
Expand All @@ -28,8 +29,7 @@ function customQuery(collectionObj, filter, sort, limit, batchSize, streamified,
if (streamified) {
stream = cursor.sort({$natural: -1}).stream();
stream.on('data', function (document) {
document.time = document.t;
document.data = (document.d === undefined ? document.key : document.d);
document.d = (document.d === undefined ? document.key : document.d);
documentHandler(document);
});
}
Expand All @@ -52,7 +52,8 @@ function customQuery(collectionObj, filter, sort, limit, batchSize, streamified,

// A null name indicates that there are no more results.
if (document) {
documentHandler({id: document._id, time: document.t, data: (document.d === undefined ? document.key : document.d)});
document.d = (document.d === undefined ? document.key : document.d);
documentHandler(document);
}
else {
documentHandler(null);
Expand Down Expand Up @@ -160,6 +161,7 @@ module.exports = function (db) {
if (document) {
streams.active.forEach(function (documentHandler) {
if (!documentHandler.closed) {
console.log("document handled: " + util.inspect(document, {colors: true, depth: null}));
documentHandler(document);
}
});
Expand Down
Loading

0 comments on commit f3f6feb

Please sign in to comment.