Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added logs per user/app

  • Loading branch information...
commit 51145635d06fa6b78e4bd739d1c67e2612f65bb7 1 parent b054cdb
Hadrien Jouet authored

Showing 2 changed files with 30 additions and 2 deletions. Show diff stats Hide diff stats

  1. +24 0 lib/ishiki.js
  2. +6 2 models/_base.js
24 lib/ishiki.js
@@ -272,5 +272,29 @@ module.exports = function(app, haibu, path, fs, drone, proxy) {
272 272 });
273 273 });
274 274 });
  275 +
  276 + //return logs for given user/app
  277 + this.get('/:userid/:appid/logs', function(userid, appid) {
  278 + var res = this.res,
  279 + filter = {},
  280 + options = {limit: 10, sort: {$natural: -1}};
  281 +
  282 + options.user = userid;
  283 + options.app = appid;
  284 +
  285 + if (this.req.body) {
  286 + if (this.req.body.type)
  287 + filter.type = this.req.body.type;
  288 + if (this.req.body.limit)
  289 + options.limit = this.req.body.limit.toInt();
  290 + }
  291 +
  292 + logModel.get(filter, options, function(err, results) {
  293 + if (err)
  294 + return haibu.sendResponse(res, 500, err);
  295 +
  296 + haibu.sendResponse(res, 200, results);
  297 + });
  298 + });
275 299 });
276 300 };
8 models/_base.js
@@ -7,7 +7,11 @@ var BaseModel = exports.BaseModel = function(options) {
7 7 };
8 8
9 9 //retrieve one entry if id passed, or several if {} passed
10   -BaseModel.prototype.get = function(filter, callback) {
  10 +BaseModel.prototype.get = function(filter, options, callback) {
  11 + if (!callback) {
  12 + callback = options;
  13 + options = {};
  14 + }
11 15 if (!callback) {
12 16 callback = filter;
13 17 filter = {};
@@ -27,7 +31,7 @@ BaseModel.prototype.get = function(filter, callback) {
27 31 });
28 32 }
29 33 else if (typeof filter == 'object') {
30   - collection.find(filter).toArray(function(err, data) {
  34 + collection.find(filter, {}, options).toArray(function(err, data) {
31 35 if (err)
32 36 callback(err);
33 37 else

0 comments on commit 5114563

Please sign in to comment.
Something went wrong with that request. Please try again.