el-borracho-stats
Version:
REST and SSE API and worker producing daily and all-time totals for Bull queues
162 lines (149 loc) • 5.66 kB
JavaScript
// Generated by IcedCoffeeScript 108.0.11
var ElBorrachoStatsController, errify, __iced_k, __iced_k_noop,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
__iced_k = __iced_k_noop = function() {};
errify = require("errify");
ElBorrachoStatsController = (function() {
function ElBorrachoStatsController(_arg) {
this.redis = _arg.redis, this.namespace = _arg.namespace;
this.queueTotal = __bind(this.queueTotal, this);
this.queueHistory = __bind(this.queueHistory, this);
this.total = __bind(this.total, this);
this.history = __bind(this.history, this);
this.Store = require("./models/stats");
this.stores = {};
this.store = new this.Store({
redis: this.redis,
namespace: this.namespace
});
}
ElBorrachoStatsController.prototype.history = function(req, res, next) {
var days_previous, ideally, start_date, stats, ___iced_passed_deferral, __iced_deferrals, __iced_k, _ref;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
ideally = errify(next);
_ref = req.query, start_date = _ref.start_date, days_previous = _ref.days_previous;
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "/home/charles/source/el-borracho-stats/src/el-borracho-stats.coffee",
funcname: "ElBorrachoStatsController.history"
});
_this.store.fetchHistoryForAll(start_date, days_previous, ideally(__iced_deferrals.defer({
assign_fn: (function() {
return function() {
return stats = arguments[0];
};
})(),
lineno: 14
})));
__iced_deferrals._fulfill();
});
})(this)((function(_this) {
return function() {
return res.json(stats);
};
})(this));
};
ElBorrachoStatsController.prototype.total = function(req, res, next) {
var ideally, total, ___iced_passed_deferral, __iced_deferrals, __iced_k;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
ideally = errify(next);
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "/home/charles/source/el-borracho-stats/src/el-borracho-stats.coffee",
funcname: "ElBorrachoStatsController.total"
});
_this.store.fetchForAll(ideally(__iced_deferrals.defer({
assign_fn: (function() {
return function() {
return total = arguments[0];
};
})(),
lineno: 21
})));
__iced_deferrals._fulfill();
});
})(this)((function(_this) {
return function() {
return res.json(total);
};
})(this));
};
ElBorrachoStatsController.prototype.queueHistory = function(req, res, next) {
var days_previous, ideally, queue, start_date, stats, store, ___iced_passed_deferral, __iced_deferrals, __iced_k, _ref;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
ideally = errify(next);
queue = req.param.queue;
_ref = req.query, start_date = _ref.start_date, days_previous = _ref.days_previous;
store = this.storeCache(queue);
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "/home/charles/source/el-borracho-stats/src/el-borracho-stats.coffee",
funcname: "ElBorrachoStatsController.queueHistory"
});
store.fetchHistoryForQueue(queue, start_date, days_previous, ideally(__iced_deferrals.defer({
assign_fn: (function() {
return function() {
return stats = arguments[0];
};
})(),
lineno: 32
})));
__iced_deferrals._fulfill();
});
})(this)((function(_this) {
return function() {
return res.json(stats);
};
})(this));
};
ElBorrachoStatsController.prototype.queueTotal = function(req, res, next) {
var ideally, queue, store, total, ___iced_passed_deferral, __iced_deferrals, __iced_k;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
ideally = errify(next);
queue = req.param.queue;
store = this.storeCache(queue);
(function(_this) {
return (function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "/home/charles/source/el-borracho-stats/src/el-borracho-stats.coffee",
funcname: "ElBorrachoStatsController.queueTotal"
});
store.fetchForQueue(queue, ideally(__iced_deferrals.defer({
assign_fn: (function() {
return function() {
return total = arguments[0];
};
})(),
lineno: 42
})));
__iced_deferrals._fulfill();
});
})(this)((function(_this) {
return function() {
return res.json(total);
};
})(this));
};
ElBorrachoStatsController.prototype.storeCache = function(queuename) {
var _base;
return (_base = this.stores)[queuename] || (_base[queuename] = new this.Store({
redis: this.redis,
namespace: this.namespace,
queuename: queuename
}));
};
return ElBorrachoStatsController;
})();
module.exports = ElBorrachoStatsController;
//# sourceMappingURL=el-borracho-stats.js.map